Documentation
¶
Index ¶
- Constants
- func FilterLoop(beacon Beacon, next addr.IA, allowIsdLoop bool) error
- func PackBeacon(ps *seg.PathSegment) ([]byte, error)
- func UnpackBeacon(raw []byte) (*seg.PathSegment, error)
- type Beacon
- type ChainProvider
- type CorePolicies
- type CoreStore
- func (s *CoreStore) BeaconsToPropagate(ctx context.Context) ([]Beacon, error)
- func (s *CoreStore) InsertBeacon(ctx context.Context, beacon Beacon) (InsertStats, error)
- func (s *CoreStore) MaxExpTime(policyType PolicyType) uint8
- func (s *CoreStore) PreFilter(beacon Beacon) error
- func (s *CoreStore) SegmentsToRegister(ctx context.Context, segType seg.Type) ([]Beacon, []RegistrationPolicy, error)
- func (s *CoreStore) UpdatePolicy(ctx context.Context, policy Policy) error
- type DB
- type Filter
- type GroupedBeacons
- type InsertStats
- type Policies
- type Policy
- type PolicyType
- type RegPolicyType
- type RegistrationPolicy
- type RegistrationPolicyMatcher
- type SelectionAlgorithm
- type Store
- func (s *Store) BeaconsToPropagate(ctx context.Context) ([]Beacon, error)
- func (s *Store) InsertBeacon(ctx context.Context, beacon Beacon) (InsertStats, error)
- func (s *Store) MaxExpTime(policyType PolicyType) uint8
- func (s *Store) PreFilter(beacon Beacon) error
- func (s *Store) SegmentsToRegister(ctx context.Context, segType seg.Type) ([]Beacon, []RegistrationPolicy, error)
- func (s *Store) UpdatePolicy(ctx context.Context, policy Policy) error
- type StoreOption
- type Usage
Constants ¶
const ( // DefaultBestSetSize is the default BestSetSize value. DefaultBestSetSize = 20 // DefaultCandidateSetSize is the default CandidateSetSize value. DefaultCandidateSetSize = 100 // DefaultMaxHopsLength is the default MaxHopsLength value. DefaultMaxHopsLength = 10 // DefaultMaxExpTime is the default MaxExpTime value. DefaultMaxExpTime = uint8(63) )
const DefaultGroup string = "default"
DefaultGroup defines the default beacon group. This means that if a policy does not define any registration policies, all the beacons should be put into this group.
This should also correspond to the ID of the default plugin.
Variables ¶
This section is empty.
Functions ¶
func FilterLoop ¶
FilterLoop returns an error if the beacon contains an AS or ISD loop. If ISD loops are allowed, an error is returned only on AS loops.
func UnpackBeacon ¶
func UnpackBeacon(raw []byte) (*seg.PathSegment, error)
UnpackBeacon unpacks a beacon.
Types ¶
type Beacon ¶
type Beacon struct {
// Segment is the path segment.
Segment *seg.PathSegment
// InIfID is the interface the beacon is received on.
InIfID uint16
}
Beacon consists of the path segment and the interface it was received on.
type ChainProvider ¶ added in v0.12.0
type ChainProvider interface {
GetChains(context.Context, trust.ChainQuery, ...trust.Option) ([][]*x509.Certificate, error)
}
type CorePolicies ¶
type CorePolicies struct {
// Prop is the propagation policy.
Prop Policy
// CoreReg is the core segment policy.
CoreReg Policy
}
CorePolicies keeps track of all policies for a core beacon store.
func (*CorePolicies) Filter ¶
func (p *CorePolicies) Filter(beacon Beacon) error
Filter applies all filters and returns an error if all of them filter the beacon. If at least one does not filter, no error is returned.
func (*CorePolicies) InitDefaults ¶
func (p *CorePolicies) InitDefaults()
InitDefaults sets the defaults for all policies.
func (*CorePolicies) Usage ¶
func (p *CorePolicies) Usage(beacon Beacon) Usage
Usage returns the allowed usage of the beacon based on all available policies. For missing policies, the usage is not permitted.
func (*CorePolicies) Validate ¶
func (p *CorePolicies) Validate() error
Validate checks that each policy is of the correct type.
type CoreStore ¶
type CoreStore struct {
// contains filtered or unexported fields
}
CoreStore provides abstracted access to the beacon database in a core AS. The store helps to insert beacons and revocations, and selects the best beacons for given purposes based on the configured policies. It should not be used in a non-core AS.
func NewCoreBeaconStore ¶
func NewCoreBeaconStore(policies CorePolicies, db DB, opts ...StoreOption) (*CoreStore, error)
NewCoreBeaconStore creates a new beacon store for a core AS.
func (*CoreStore) BeaconsToPropagate ¶
BeaconsToPropagate returns a slice of all beacons to propagate at the time of the call. The selection is based on the configured propagation policy.
func (*CoreStore) InsertBeacon ¶
func (s *CoreStore) InsertBeacon(ctx context.Context, beacon Beacon) (InsertStats, error)
InsertBeacon adds a verified beacon to the store. Beacon that contains revoked interfaces is inserted and does not cause an error. If the beacon does not match any policy, it is not inserted, but does not cause an error.
func (*CoreStore) MaxExpTime ¶
func (s *CoreStore) MaxExpTime(policyType PolicyType) uint8
MaxExpTime returns the segment maximum expiration time for the given policy.
func (*CoreStore) PreFilter ¶
PreFilter indicates whether the beacon will be filtered on insert by returning an error with the reason. This allows the caller to drop ignored beacons.
func (*CoreStore) SegmentsToRegister ¶
func (s *CoreStore) SegmentsToRegister( ctx context.Context, segType seg.Type, ) ([]Beacon, []RegistrationPolicy, error)
SegmentsToRegister returns the beacons to register at the time of the call. The selection is based on the configured policy for the requested segment type.
type DB ¶
type DB interface {
// CandidateBeacons returns up to `setSize` beacons that are allowed for the
// given usage. The beacons in the slice are ordered by segment length from
// shortest to longest.
CandidateBeacons(
ctx context.Context,
setSize int,
usage Usage,
src addr.IA,
) ([]Beacon, error)
// BeaconSources returns all source ISD-AS of the beacons in the database.
BeaconSources(ctx context.Context) ([]addr.IA, error)
// InsertBeacon inserts a beacon with its allowed usage into the database.
InsertBeacon(ctx context.Context, beacon Beacon, usage Usage) (InsertStats, error)
}
DB defines the interface that all beacon DB backends have to implement.
type Filter ¶
type Filter struct {
// MaxHopsLength is the maximum number of hops a segment can have.
MaxHopsLength int `yaml:"MaxHopsLength"`
// ASBlackList contains all ASes that may not appear in a segment.
AsBlackList []addr.AS `yaml:"AsBlackList"`
// IsdBlackList contains all ISD that may not appear in a segment.
IsdBlackList []addr.ISD `yaml:"IsdBlackList"`
// AllowIsdLoop indicates whether ISD loops should not be filtered.
AllowIsdLoop *bool `yaml:"AllowIsdLoop"`
}
Filter filters beacons.
func (*Filter) InitDefaults ¶
func (f *Filter) InitDefaults()
InitDefaults initializes the default values for unset fields.
type GroupedBeacons ¶ added in v0.14.0
GroupedBeacons is a map where the key is the registration policy name and the value is a slice of beacons that should be handled by that registration policy.
type InsertStats ¶
type InsertStats struct {
Inserted, Updated, Filtered int
}
InsertStats provides statistics about an insertion.
type Policies ¶
type Policies struct {
// Prop is the propagation policy.
Prop Policy
// UpReg is the up segment policy.
UpReg Policy
// DownReg is the down segment policy.
DownReg Policy
}
Policies keeps track of all policies for a non-core beacon store.
func (*Policies) Filter ¶
Filter applies all filters and returns an error if all of them filter the beacon. If at least one does not filter, no error is returned.
func (*Policies) InitDefaults ¶
func (p *Policies) InitDefaults()
InitDefaults sets the defaults for all policies.
type Policy ¶
type Policy struct {
// BestSetSize is the number of segments to propagate or register.
BestSetSize int `yaml:"BestSetSize"`
// CandidateSetSize is the number of segments to consider for
// selection.
CandidateSetSize int `yaml:"CandidateSetSize"`
// MaxExpTime indicates the maximum value for the expiration time when
// extending the segment.
MaxExpTime *uint8 `yaml:"MaxExpTime"`
// Filter is the filter applied to segments.
Filter Filter `yaml:"Filter"`
// Type is the policy type.
Type PolicyType `yaml:"Type"`
// RegistrationPolicies contains the registration policies for this policy.
RegistrationPolicies []RegistrationPolicy `yaml:"RegistrationPolicies"`
}
Policy contains the policy parameters when handling beacons.
func LoadPolicyFromYaml ¶
func LoadPolicyFromYaml(path string, t PolicyType) (*Policy, error)
LoadPolicyFromYaml loads the policy from a yaml file and initializes the default values.
func ParsePolicyYaml ¶
func ParsePolicyYaml(r io.Reader, t PolicyType) (*Policy, error)
ParsePolicyYaml parses the policy in yaml format and initializes the default values.
func (*Policy) InitDefaults ¶
func (p *Policy) InitDefaults()
InitDefaults initializes the default values for unset fields.
type PolicyType ¶
type PolicyType string
PolicyType is the policy type.
const ( // PropPolicy is the propagation policy. PropPolicy PolicyType = "Propagation" // UpRegPolicy is the registration policy for up segments. UpRegPolicy PolicyType = "UpSegmentRegistration" // DownRegPolicy is the registration policy for down segments. DownRegPolicy PolicyType = "DownSegmentRegistration" // CoreRegPolicy is the registration policy for core segments. CoreRegPolicy PolicyType = "CoreSegmentRegistration" )
func (PolicyType) RegPolicyType ¶ added in v0.14.0
func (p PolicyType) RegPolicyType() (RegPolicyType, bool)
RegPolicyType converts a PolicyType to a RegPolicyType if it is a registration policy type. The second return value indicates whether the conversion was successful.
type RegPolicyType ¶ added in v0.14.0
type RegPolicyType string
RegPolicyType is the registration policy type, which is a subset of PolicyType.
const ( // RegPolicyTypeUp is the registration policy type for up segments. RegPolicyTypeUp RegPolicyType = RegPolicyType(UpRegPolicy) // RegPolicyTypeDown is the registration policy type for down segments. RegPolicyTypeDown RegPolicyType = RegPolicyType(DownRegPolicy) // RegPolicyTypeCore is the registration policy type for core segments. RegPolicyTypeCore RegPolicyType = RegPolicyType(CoreRegPolicy) )
func (RegPolicyType) PolicyType ¶ added in v0.14.0
func (p RegPolicyType) PolicyType() PolicyType
PolicyType converts a RegPolicyType to a generic PolicyType.
func (RegPolicyType) SegmentType ¶ added in v0.14.0
func (p RegPolicyType) SegmentType() segment.Type
SegmentType returns the segment type associated with this registration policy.
type RegistrationPolicy ¶ added in v0.14.0
type RegistrationPolicy struct {
Name string `yaml:"Name"`
Description string `yaml:"Description"`
Matcher RegistrationPolicyMatcher `yaml:"Matcher"`
Plugin string `yaml:"Plugin"`
PluginConfig map[string]any `yaml:"PluginConfig"`
}
RegistrationPolicy contains the parameters for a registration policy. A registration policy is used to register segments with a registrar.
func (*RegistrationPolicy) InitDefaults ¶ added in v0.14.0
func (p *RegistrationPolicy) InitDefaults()
InitDefaults initializes the default values for unset fields in the registration policy.
func (*RegistrationPolicy) Validate ¶ added in v0.14.0
func (p *RegistrationPolicy) Validate() error
type RegistrationPolicyMatcher ¶ added in v0.14.0
type RegistrationPolicyMatcher struct {
Sequence *pathpol.Sequence `yaml:"Sequence"`
ACL *pathpol.ACL `yaml:"ACL"`
}
RegistrationPolicyMatcher contains the matching criteria for a registration policy. A matcher is valid only if at least one of Sequence and ACL fields are set.
func (*RegistrationPolicyMatcher) Match ¶ added in v0.14.0
func (m *RegistrationPolicyMatcher) Match(beacon Beacon) bool
Match returns true iff the given beacon matches the registration policy matcher. Note that an empty matcher is invalid, and it always returns false.
type SelectionAlgorithm ¶ added in v0.15.0
type SelectionAlgorithm interface {
// SelectBeacons selects the `resultSize` best beacons from the provided slice of beacons.
SelectBeacons(ctx context.Context, beacons []Beacon, resultSize int) []Beacon
}
func DefaultSelectionAlgorithm ¶ added in v0.15.0
func DefaultSelectionAlgorithm() SelectionAlgorithm
DefaultSelectionAlgorithm implements a very simple selection algorithm that optimizes for short paths, but also tries to achieve minimal path diversity.
func NewChainsAvailableAlgo ¶ added in v0.15.0
func NewChainsAvailableAlgo(engine ChainProvider, selector SelectionAlgorithm) SelectionAlgorithm
NewChainsAvailableAlgo creates a SelectionAlgorithm that filters beacons based on the availability of their verification chains before passing them to the provided selector. This can be paired with a chain provider that only returns locally available chains to ensure that beacons are verifiable with cryptographic material available in the local trust store.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store provides abstracted access to the beacon database in a non-core AS. The store helps to insert beacons and revocations, and selects the best beacons for given purposes based on the configured policies. It should not be used in a core AS.
func NewBeaconStore ¶
func NewBeaconStore(policies Policies, db DB, opts ...StoreOption) (*Store, error)
NewBeaconStore creates a new beacon store for a non-core AS.
func (*Store) BeaconsToPropagate ¶
BeaconsToPropagate returns a slice of all beacons to propagate at the time of the call. The selection is based on the configured propagation policy.
func (*Store) InsertBeacon ¶
func (s *Store) InsertBeacon(ctx context.Context, beacon Beacon) (InsertStats, error)
InsertBeacon adds a verified beacon to the store. Beacon that contains revoked interfaces is inserted and does not cause an error. If the beacon does not match any policy, it is not inserted, but does not cause an error.
func (*Store) MaxExpTime ¶
func (s *Store) MaxExpTime(policyType PolicyType) uint8
MaxExpTime returns the segment maximum expiration time for the given policy.
func (*Store) PreFilter ¶
PreFilter indicates whether the beacon will be filtered on insert by returning an error with the reason. This allows the caller to drop ignored beacons.
func (*Store) SegmentsToRegister ¶
func (s *Store) SegmentsToRegister( ctx context.Context, segType seg.Type, ) ([]Beacon, []RegistrationPolicy, error)
SegmentsToRegister returns all beacons to register at the time of the call. The selections are based on the configured policy for the requested segment type.
type StoreOption ¶ added in v0.12.0
type StoreOption interface {
// contains filtered or unexported methods
}
func WithSelectionAlgorithm ¶ added in v0.15.0
func WithSelectionAlgorithm(algo SelectionAlgorithm) StoreOption
WithSelectionAlgorithm sets the selection algorithm used to select the best beacons according to the configured policies.
type Usage ¶
type Usage int
Usage indicates what the beacon is allowed to be used for according to the policies.
const ( // UsageUpReg indicates the beacon is allowed to be registered as an up segment. UsageUpReg Usage = 0x01 // UsageDownReg indicates the beacon is allowed to be registered as a down segment. UsageDownReg Usage = 0x02 // UsageCoreReg indicates the beacon is allowed to be registered as a core segment. UsageCoreReg Usage = 0x04 // UsageProp indicates the beacon is allowed to be propagated. UsageProp Usage = 0x08 )
func UsageFromPolicyType ¶
func UsageFromPolicyType(policyType PolicyType) Usage
UsageFromPolicyType maps the policy type to the usage flag.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package mock_beacon is a generated GoMock package.
|
Package mock_beacon is a generated GoMock package. |