Documentation
¶
Overview ¶
Package segfetcher contains all the logic that is needed to fetch segments, verify and store segments in an efficient manner. It is designed to be pluggable into sciond and PS.
Index ¶
- Variables
- func DeleteNextQueryEntries(ctx context.Context, tx pathdb.Transaction, results query.Results) error
- func ErrToMetricsLabel(err error) string
- type DefaultRequester
- type DefaultResolver
- type DstProvider
- type Fetcher
- type FetcherConfig
- type LocalInfo
- type MultiSegmentSplitter
- type NextQueryCleaner
- type Pather
- type ReplyHandler
- type ReplyOrErr
- type Request
- type RequestAPI
- type RequestSet
- type RequestState
- type Requester
- type Requests
- type Resolver
- type Segments
- type Splitter
- type Validator
Constants ¶
This section is empty.
Variables ¶
var ( ErrBadDst = errors.New("bad destination AS") ErrNoPaths = errors.New("no paths found") )
Pather errors.
var ErrInvalidRequest = serrors.New("invalid request")
ErrInvalidRequest indicates an invalid request.
Functions ¶
func DeleteNextQueryEntries ¶
func DeleteNextQueryEntries(ctx context.Context, tx pathdb.Transaction, results query.Results) error
DeleteNextQueryEntries deletes all NextQuery entries that are described by the given query result set.
func ErrToMetricsLabel ¶
ErrToMetricsLabel classifies the error from the segfetcher into metrics labels.
Types ¶
type DefaultRequester ¶
type DefaultRequester struct { API RequestAPI DstProvider DstProvider }
DefaultRequester requests all segments that can be requested from a request set.
func (*DefaultRequester) Request ¶
func (r *DefaultRequester) Request(ctx context.Context, req RequestSet) <-chan ReplyOrErr
Request all requests in the request set that are in fetch state.
type DefaultResolver ¶
DefaultResolver is the default resolver implementation.
func NewResolver ¶
NewResolver creates a new resolver with the given DB. The DB might be customized. E.g. a PS could inject a wrapper around GetNextQuery so that it always returns that the cache is up to date for segments that should be available local.
func (*DefaultResolver) Resolve ¶
func (r *DefaultResolver) Resolve(ctx context.Context, segs Segments, req RequestSet) (Segments, RequestSet, error)
Resolve resolves a request set. It returns the segments that are locally stored and the set of requests that have to be requested at a remote server.
type DstProvider ¶
DstProvider provides the destination for a segment lookup.
type Fetcher ¶
type Fetcher struct { Validator Validator Splitter Splitter Resolver Resolver Requester Requester ReplyHandler ReplyHandler PathDB pathdb.PathDB QueryInterval time.Duration NextQueryCleaner NextQueryCleaner CryptoLookupAtLocalCS bool // contains filtered or unexported fields }
Fetcher fetches, verifies and stores segments for a given path request.
type FetcherConfig ¶
type FetcherConfig struct { // QueryInterval specifies after how much time segments should be // refetched at the remote server. QueryInterval time.Duration // LocalIA is the IA this process is in. LocalIA addr.IA // VerificationFactory is the verification factory to use. VerificationFactory infra.VerificationFactory // PathDB is the path db to use. PathDB pathdb.PathDB // RevCache is the revocation cache to use. RevCache revcache.RevCache // RequestAPI is the request api to use. RequestAPI RequestAPI // DstProvider provides destinations to fetch segments from DstProvider DstProvider // Validator is used to validate requests. Validator Validator // Splitter is used to split requests. Splitter Splitter // SciondMode enables sciond mode, this means it uses the local CS to fetch // crypto material and considers revocations in the path lookup. SciondMode bool // MetricsNamespace is the namespace used for metrics. MetricsNamespace string // LocalInfo provides information about local segments. LocalInfo LocalInfo }
FetcherConfig is the configuration for the fetcher.
func (FetcherConfig) New ¶
func (cfg FetcherConfig) New() *Fetcher
New creates a new fetcher from the configuration.
type LocalInfo ¶ added in v0.5.0
type LocalInfo interface { // IsSegLocal returns whether this segment should always be locally cached. IsSegLocal(ctx context.Context, src, dst addr.IA) (bool, error) }
LocalInfo provides information about which segments are always locally stored.
type MultiSegmentSplitter ¶ added in v0.5.0
type MultiSegmentSplitter struct { Local addr.IA Inspector infra.ASInspector }
MultiSegmentSplitter splits requests consisting of one or multiple segments. The AS inspector is used to check whether an IA is core or not.
func (*MultiSegmentSplitter) Split ¶ added in v0.5.0
func (s *MultiSegmentSplitter) Split(ctx context.Context, r Request) (RequestSet, error)
Split splits the request consisting of one or multiple segments.
type NextQueryCleaner ¶
NextQueryCleaner can be used to delete next query entries from a pathdb.
func (*NextQueryCleaner) ResetQueryCache ¶
ResetQueryCache deletes all NextQuery entries for segments that contain the revoked interface.
type Pather ¶ added in v0.5.0
type Pather struct { PathDB pathdb.PathDB RevCache revcache.RevCache TopoProvider topology.Provider Fetcher *Fetcher }
Pather is used to construct paths from the path database. If necessary, paths are fetched over the network.
func (*Pather) GetPaths ¶ added in v0.5.0
func (p *Pather) GetPaths(ctx context.Context, dst addr.IA, refresh bool) ([]*combinator.Path, error)
GetPaths returns all non-revoked and non-expired paths to the destination. The paths are sorted from best to worst according to the weighting in path combinator. In case the destination AS is the same as the local AS, a slice containing an empty path is returned.
type ReplyHandler ¶
type ReplyHandler interface { Handle(ctx context.Context, recs seghandler.Segments, server net.Addr, earlyTrigger <-chan struct{}) *seghandler.ProcessedResult }
ReplyHandler handles replies.
type ReplyOrErr ¶
ReplyOrErr is a seg reply or an error for the given request.
type Request ¶
type Request struct { Src addr.IA Dst addr.IA State RequestState }
Request represents a path or segment request.
type RequestAPI ¶
type RequestAPI interface { GetSegs(ctx context.Context, msg *path_mgmt.SegReq, a net.Addr, id uint64) (*path_mgmt.SegReply, error) }
RequestAPI is the API to get segments from the network.
type RequestSet ¶
type RequestSet struct { Up Request Cores Requests Down Request // Fetch indicates the request should always be fetched from remote, // regardless of whether is is cached. Fetch bool }
RequestSet is a set of requests.
func (RequestSet) IsLoaded ¶
func (r RequestSet) IsLoaded() bool
IsLoaded returns true if all non-zero requests in the set are in state loaded.
type RequestState ¶
type RequestState int
RequestState is the state the request is in.
const ( // Unresolved means the request is not yet resolved. Unresolved RequestState = iota // Fetch means the request needs to be fetched. Fetch // Cached means the request should be cached locally and can be loaded from // DB. Cached // Fetched means the request has been fetched and should be in the DB. Fetched // Loaded means the request has been loaded from the DB. Loaded )
type Requester ¶
type Requester interface {
Request(ctx context.Context, req RequestSet) <-chan ReplyOrErr
}
Requester requests segments.
type Requests ¶
type Requests []Request
Requests is a list of requests and provides some convenience methods on top of it.
type Resolver ¶
type Resolver interface { // Resolve resolves a request set. It returns the segments that are locally // stored and the set of requests that have to be requested at a remote server. Resolve(ctx context.Context, segs Segments, req RequestSet) (Segments, RequestSet, error) }
Resolver resolves segments that are locally cached.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
internal
|
|
Package mock_segfetcher is a generated GoMock package.
|
Package mock_segfetcher is a generated GoMock package. |