Documentation
¶
Index ¶
- Constants
- func ScaleExpirationQuantumForTests(factor uint)
- func SliceHas(facts []*Fact, predicate func(*Fact) bool) bool
- type Attribute
- type EmptyValue
- type Fact
- func (f *Fact) DecodeFrom(lengthHint int, now time.Time, reader io.Reader) error
- func (f *Fact) FancyString(subjectFormatter func(s Subject) string, now time.Time) string
- func (f *Fact) MarshalBinary() ([]byte, error)
- func (f *Fact) MarshalBinaryNow(now time.Time) ([]byte, error)
- func (f *Fact) String() string
- type GroupAccumulator
- type IPNetValue
- type IPPortValue
- type Key
- type PeerSubject
- type SignedGroupValue
- type Subject
- type UUIDValue
- type Value
Constants ¶
const SignedGroupMaxSafeInnerLength = UDPMaxSafePayload - sgvFactOverhead - sgvOverhead
SignedGroupMaxSafeInnerLength is the maximum safe length for `InnerBytes` above which fragmentation or packet drops may happen. This is computed based on the max safe UDP payload for IPv6, minus the fact & crypto overheads.
const UDPMaxSafePayload = 1212
UDPMaxSafePayload is the maximum payload size of a UDP packet we can safely send. we only need to worry about IPv6 for this
Variables ¶
This section is empty.
Functions ¶
func ScaleExpirationQuantumForTests ¶ added in v0.10.0
func ScaleExpirationQuantumForTests(factor uint)
ScaleExpirationQuantumForTests reconfigures how the fact TTL is represented on the wire to permit faster than normal tests
Types ¶
type Attribute ¶
type Attribute byte
Attribute is a byte identifying what aspect of a Subject a Fact describes
const ( AttributeUnknown Attribute = 0 AttributeAlive Attribute = '!' AttributeEndpointV4 Attribute = 'e' AttributeEndpointV6 Attribute = 'E' AttributeAllowedCidrV4 Attribute = 'a' AttributeAllowedCidrV6 Attribute = 'A' AttributeMember Attribute = 'm' // A signed group is a bit different from other facts // in this case, the subject is actually the source, // and the value is a signed aggregate of other facts. AttributeSignedGroup Attribute = 'S' )
fact types, denoted as attributes of a subject
type EmptyValue ¶
type EmptyValue struct{}
EmptyValue is currently used as a placeholder in Membership facts
func (EmptyValue) DecodeFrom ¶ added in v0.6.0
func (v EmptyValue) DecodeFrom(lengthHint int, reader io.Reader) error
DecodeFrom implements Decodable
func (EmptyValue) MarshalBinary ¶ added in v0.6.0
func (v EmptyValue) MarshalBinary() ([]byte, error)
MarshalBinary always returns an empty slice for EmptyValue
func (EmptyValue) String ¶
func (v EmptyValue) String() string
type Fact ¶
type Fact struct {
encoding.BinaryMarshaler
util.Decodable
Attribute Attribute
Expires time.Time
Subject Subject
Value Value
}
Fact represents a single piece of information about a subject, with an associated expiration time
func SortedCopy ¶
SortedCopy makes a copy of the list and then sorts it "naturally"
func (*Fact) DecodeFrom ¶ added in v0.6.0
DecodeFrom implements Decodable
func (*Fact) FancyString ¶ added in v0.3.0
FancyString formats the fact as a string using a custom helper to format the subject, most commonly to replace peer keys with names
func (*Fact) MarshalBinary ¶ added in v0.6.0
MarshalBinary serializes a Fact to its on-wire format
func (*Fact) MarshalBinaryNow ¶ added in v0.9.0
MarshalBinaryNow is like MarshalBinary, except it uses a provided value of `now` so that the output is deterministic
type GroupAccumulator ¶ added in v0.2.0
type GroupAccumulator struct {
// contains filtered or unexported fields
}
GroupAccumulator is a helper to aggregate individual facts into (signed) groups of a max size
func NewAccumulator ¶ added in v0.2.0
func NewAccumulator(maxGroupLen int, now time.Time) *GroupAccumulator
NewAccumulator initializes a new GroupAccumulator with a given max inner size per group.
func (*GroupAccumulator) AddFact ¶ added in v0.2.0
func (ga *GroupAccumulator) AddFact(f *Fact) error
AddFact appends the given fact into the accumulator
func (*GroupAccumulator) AddFactIfRoom ¶ added in v0.2.1
func (ga *GroupAccumulator) AddFactIfRoom(f *Fact) (added bool, err error)
AddFactIfRoom conditionally adds the fact if and only if it won't result in creating a new group
func (*GroupAccumulator) MakeSignedGroups ¶ added in v0.2.0
func (ga *GroupAccumulator) MakeSignedGroups( s *signing.Signer, recipient *wgtypes.Key, ) ([]Fact, error)
MakeSignedGroups converts all the accumulated facts into SignedGroups of no more than the specified max inner size.
type IPNetValue ¶
IPNetValue represents some IP+Mask as an Attribute of a Subject
func (*IPNetValue) DecodeFrom ¶ added in v0.6.0
func (ipn *IPNetValue) DecodeFrom(lengthHint int, reader io.Reader) error
DecodeFrom implements Decodable
func (IPNetValue) MarshalBinary ¶ added in v0.6.0
func (ipn IPNetValue) MarshalBinary() ([]byte, error)
MarshalBinary gives the binary representation of the ip and cidr prefix
func (*IPNetValue) UnmarshalBinary ¶ added in v0.6.0
func (ipn *IPNetValue) UnmarshalBinary(data []byte) error
UnmarshalBinary implements BinaryUnmarshaler
type IPPortValue ¶
IPPortValue represents an IP:port pair as an Attribute of a Subject
func (*IPPortValue) DecodeFrom ¶ added in v0.6.0
func (ipp *IPPortValue) DecodeFrom(lengthHint int, reader io.Reader) error
DecodeFrom implements Decodable
func (*IPPortValue) MarshalBinary ¶ added in v0.6.0
func (ipp *IPPortValue) MarshalBinary() ([]byte, error)
MarshalBinary returns the normalized binary representation
func (*IPPortValue) String ¶
func (ipp *IPPortValue) String() string
func (*IPPortValue) UnmarshalBinary ¶ added in v0.6.0
func (ipp *IPPortValue) UnmarshalBinary(data []byte) error
UnmarshalBinary implements BinaryUnmarshaler
type Key ¶
type Key struct {
// contains filtered or unexported fields
}
Key is a comparable version of the subject, attribute, and value of a Fact
type PeerSubject ¶
PeerSubject is a subject that is a peer identified via its public key
func (*PeerSubject) DecodeFrom ¶ added in v0.6.0
func (s *PeerSubject) DecodeFrom(lengthHint int, reader io.Reader) error
DecodeFrom implements Decodable
func (*PeerSubject) MarshalBinary ¶ added in v0.6.0
func (s *PeerSubject) MarshalBinary() ([]byte, error)
MarshalBinary implements encoding.BinaryMarshaler
func (*PeerSubject) UnmarshalBinary ¶ added in v0.6.0
func (s *PeerSubject) UnmarshalBinary(data []byte) error
UnmarshalBinary implements BinaryUnmarshaler
type SignedGroupValue ¶ added in v0.2.0
type SignedGroupValue struct {
Nonce [chacha20poly1305.NonceSizeX]byte
Tag [poly1305.TagSize]byte
InnerBytes []byte
}
SignedGroupValue represents a signed chunk of other fact data. Note that this structure does _not_ include parsing those inner bytes!
func (*SignedGroupValue) DecodeFrom ¶ added in v0.6.0
func (sgv *SignedGroupValue) DecodeFrom(lengthHint int, reader io.Reader) error
DecodeFrom implements Decodable
func (*SignedGroupValue) MarshalBinary ¶ added in v0.6.0
func (sgv *SignedGroupValue) MarshalBinary() ([]byte, error)
MarshalBinary gives the on-wire form of the value
func (*SignedGroupValue) ParseInner ¶ added in v0.2.0
func (sgv *SignedGroupValue) ParseInner(now time.Time) (ret []*Fact, err error)
ParseInner parses the inner bytes of a SignedGroupValue into facts. Validating the signature must be done separately, and should be done before calling this method.
func (*SignedGroupValue) String ¶ added in v0.2.0
func (sgv *SignedGroupValue) String() string