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 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, error)
- func (s *CoreStore) UpdatePolicy(ctx context.Context, policy Policy) error
- type DB
- type Filter
- type InsertStats
- type Policies
- type Policy
- type PolicyType
- 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, error)
- func (s *Store) UpdatePolicy(ctx context.Context, policy Policy) error
- type Usage
Constants ¶
const ( // ErrReadingRows is the error message in case we fail to read more from // the database. ErrReadingRows common.ErrMsg = "Failed to read rows" // ErrParse is the error message in case the parsing a db entry fails. ErrParse common.ErrMsg = "Failed to parse entry" )
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) )
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 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 inserting 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) (*CoreStore, error)
NewCoreBeaconStore creates a new beacon store for a non-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 ¶
SegmentsToRegister returns a slice of all beacons to register at the time of the call. The selections 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) // Insert 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 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"` }
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(b []byte, 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" )
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 inserting 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 ¶
NewBeaconStore creates a new beacon store for a non-core AS.
func (*Store) BeaconsToPropagate ¶
BeaconsToPropagate returns a slice 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 ¶
SegmentsToRegister returns a channel that provides all beacons to register at the time of the call. The selections is based on the configured policy for the requested segment type.
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.
Directories ¶
Path | Synopsis |
---|---|
Package mock_beacon is a generated GoMock package.
|
Package mock_beacon is a generated GoMock package. |