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 NextQueryCleaner
- 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 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 // ASInspector is the as inspector to use. ASInspector infra.ASInspector // 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 // The namespace used for metrics. MetricsNamespace string }
FetcherConfig is the configuration for the fetcher.
func (FetcherConfig) New ¶
func (cfg FetcherConfig) New() *Fetcher
New creates a new fetcher from the configuration.
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 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 ¶
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. |