fact

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 22, 2019 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attribute

type Attribute byte

Attribute is a byte identifying what aspect of a Subject a Fact describes

const (
	AttributeUnknown       Attribute = 0
	AttributeEndpointV4    Attribute = 'e'
	AttributeEndpointV6    Attribute = 'E'
	AttributeAllowedCidrV4 Attribute = 'a'
	AttributeAllowedCidrV6 Attribute = 'A'
)

fact types, denoted as attributes of a subject

type EmptyValue

type EmptyValue struct{}

EmptyValue is used to represent facts of AttributeUnknown with a zero length value, which indicate just that a remote peer is alive and talking to us

func (EmptyValue) Bytes

func (v EmptyValue) Bytes() []byte

Bytes always returns an empty slice for EmptyValue

func (EmptyValue) String

func (v EmptyValue) String() string

type Fact

type Fact struct {
	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 MergeList

func MergeList(facts []*Fact) []*Fact

MergeList merges duplicate facts in a slice, keeping the latest Expires value

func Parse

func Parse(p *OnWire) (f *Fact, err error)

Parse tries to parse the intermediate packet format to a full data structure

func SortedCopy

func SortedCopy(facts []*Fact) []*Fact

SortedCopy makes a copy of the list and then sorts it "naturally"

func (*Fact) String

func (f *Fact) String() string

func (*Fact) ToWire

func (f *Fact) ToWire() (p *OnWire, err error)

ToWire turns a structured fact into its intermediate wire format

type IPNetValue

type IPNetValue struct {
	net.IPNet
}

IPNetValue represents some IP+Mask as an Attribute of a Subject

func ParseCidrV4

func ParseCidrV4(data []byte) (*IPNetValue, error)

ParseCidrV4 parses a bytes value as an IPv4 address and CIDR prefix

func ParseCidrV6

func ParseCidrV6(data []byte) (*IPNetValue, error)

ParseCidrV6 parses a bytes value as an IPv6 address and CIDR prefix

func (IPNetValue) Bytes

func (ipn IPNetValue) Bytes() []byte

Bytes gives the binary representation of the ip and cidr prefix

func (IPNetValue) String

func (ipn IPNetValue) String() string

type IPPortValue

type IPPortValue struct {
	IP   net.IP
	Port int
}

IPPortValue represents an IP:port pair as an Attribute of a Subject

func ParseEndpointV4

func ParseEndpointV4(data []byte) (*IPPortValue, error)

ParseEndpointV4 parses a bytes value as an IPv4 address and port pair

func ParseEndpointV6

func ParseEndpointV6(data []byte) (*IPPortValue, error)

ParseEndpointV6 parses a bytes value as an IPv6 address and port pair

func (*IPPortValue) Bytes

func (ipp *IPPortValue) Bytes() []byte

Bytes returns the normalized binary representation

func (*IPPortValue) String

func (ipp *IPPortValue) String() string

type Key

type Key struct {
	// contains filtered or unexported fields
}

Key is a comparable version of the subject, attribute, and value of a Fact

func KeyOf

func KeyOf(fact *Fact) Key

KeyOf returns the FactKey for a Fact

type OnWire

type OnWire struct {
	// contains filtered or unexported fields
}

OnWire is the intermediate representation of fact packet on the wire

func Deserialize

func Deserialize(data []byte) (*OnWire, error)

Deserialize tries to turn a packet from the wire into the intermediate structure

func (*OnWire) Serialize

func (f *OnWire) Serialize() ([]byte, error)

Serialize turns an on-the-wire fact into a byte array that can be sent

type PeerSubject

type PeerSubject struct {
	wgtypes.Key
}

PeerSubject is a subject that is a peer identified via its public key

func ParsePeerSubject

func ParsePeerSubject(data []byte) (*PeerSubject, error)

ParsePeerSubject parses bytes from the wire into a peer subject object

func (*PeerSubject) Bytes

func (s *PeerSubject) Bytes() []byte

Bytes gives the binary representation of a peer's public key

type Subject

type Subject interface {
	fmt.Stringer
	Bytes() []byte
}

Subject is the subject of a Fact

type Value

type Value interface {
	fmt.Stringer
	Bytes() []byte
}

Value represents the value of a Fact

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL