Documentation ¶
Index ¶
- Constants
- Variables
- func DrawPeerGraph(ctx context.Context, g PeerGraph, w io.Writer) error
- func EvalRole(role Role, action *v1.RBACAction) bool
- func EvalRule(rule *v1.Rule, action *v1.RBACAction) bool
- func FeaturePortEqual(a, b *v1.FeaturePort) bool
- func FeaturePortsEqual(a, b []*v1.FeaturePort) bool
- func IsReservedPrefix(key []byte) bool
- func MeshNodesEqual(a, b MeshNode) bool
- func ToPrefixes(ss []string) []netip.Prefix
- func ValidateACL(acl NetworkACL) error
- func ValidateRoute(route Route) error
- func WireGuardPeerEqual(a, b *v1.WireGuardPeer) bool
- func WireGuardPeersEqual(a, b []*v1.WireGuardPeer) bool
- type AdjacencyMap
- type Edge
- type EdgeMap
- type Group
- type MeshEdge
- func (e MeshEdge) AsGraphEdge() graph.Edge[NodeID]
- func (e MeshEdge) DeepCopy() MeshEdge
- func (e MeshEdge) DeepCopyInto(edge *MeshEdge)
- func (e MeshEdge) EdgeProperties() graph.EdgeProperties
- func (e MeshEdge) MarshalJSON() ([]byte, error)
- func (e MeshEdge) PutInto(ctx context.Context, g PeerGraph) error
- func (e MeshEdge) SourceID() NodeID
- func (e MeshEdge) TargetID() NodeID
- func (e MeshEdge) ToEdge() Edge
- func (e *MeshEdge) UnmarshalJSON(data []byte) error
- type MeshNode
- func (n MeshNode) DNSPort() uint16
- func (n MeshNode) DeepCopy() MeshNode
- func (n MeshNode) DeepCopyInto(node *MeshNode)
- func (n MeshNode) DeepEqual(node MeshNode) bool
- func (n MeshNode) HasFeature(feature v1.Feature) bool
- func (n MeshNode) MarshalJSON() ([]byte, error)
- func (n MeshNode) NodeID() NodeID
- func (n MeshNode) PortFor(feature v1.Feature) uint16
- func (n MeshNode) PrivateAddrV4() netip.Prefix
- func (n MeshNode) PrivateAddrV6() netip.Prefix
- func (n MeshNode) PrivateDNSAddrV4() netip.AddrPort
- func (n MeshNode) PrivateDNSAddrV6() netip.AddrPort
- func (n MeshNode) PrivateRPCAddrV4() netip.AddrPort
- func (n MeshNode) PrivateRPCAddrV6() netip.AddrPort
- func (n MeshNode) PrivateStorageAddrV4() netip.AddrPort
- func (n MeshNode) PrivateStorageAddrV6() netip.AddrPort
- func (n MeshNode) PrivateTURNAddrV4() netip.AddrPort
- func (n MeshNode) PrivateTURNAddrV6() netip.AddrPort
- func (n MeshNode) PublicDNSAddr() netip.AddrPort
- func (n MeshNode) PublicRPCAddr() netip.AddrPort
- func (n MeshNode) RPCPort() uint16
- func (n MeshNode) StoragePort() uint16
- func (n MeshNode) TURNPort() uint16
- func (n *MeshNode) UnmarshalJSON(data []byte) error
- type NetworkACL
- func (n NetworkACL) DeepCopy() NetworkACL
- func (n NetworkACL) DeepCopyInto(acl *NetworkACL)
- func (a NetworkACL) DestinationPrefixes() []netip.Prefix
- func (a NetworkACL) Equals(other NetworkACL) bool
- func (a NetworkACL) MarshalJSON() ([]byte, error)
- func (acl NetworkACL) Matches(ctx context.Context, action NetworkAction) bool
- func (a NetworkACL) Proto() *v1.NetworkACL
- func (a NetworkACL) SourcePrefixes() []netip.Prefix
- func (a *NetworkACL) UnmarshalJSON(data []byte) error
- type NetworkACLs
- func (a NetworkACLs) Accept(ctx context.Context, action NetworkAction) bool
- func (a NetworkACLs) AllowNodesToCommunicate(ctx context.Context, nodeA, nodeB MeshNode) bool
- func (a NetworkACLs) Len() int
- func (a NetworkACLs) Less(i, j int) bool
- func (a NetworkACLs) Proto() []*v1.NetworkACL
- func (a NetworkACLs) Sort(direction SortDirection)
- func (a NetworkACLs) Swap(i, j int)
- type NetworkAction
- type NodeID
- type PeerGraph
- type PeerGraphStore
- type Prefix
- type Role
- type RoleBinding
- type RolesList
- type Route
- type Routes
- type SortDirection
- type SortedWireGuardPeers
Constants ¶
const (
// GroupReference is the prefix of a node name that indicates it is a group reference.
GroupReference = "group:"
)
Variables ¶
var ReservedPrefixes = []Prefix{ RegistryPrefix, ConsensusPrefix, }
ReservedPrefixes is a list of all reserved prefixes.
Functions ¶
func DrawPeerGraph ¶
DrawPeerGraph draws a PeerGraph to the given writer in DOT format.
func EvalRole ¶
func EvalRole(role Role, action *v1.RBACAction) bool
EvalRole evaluates an action against a single role.
func EvalRule ¶
func EvalRule(rule *v1.Rule, action *v1.RBACAction) bool
EvalRule evaluates an action against a single rule.
func FeaturePortEqual ¶
func FeaturePortEqual(a, b *v1.FeaturePort) bool
FeaturePortEqual compares two feature ports for equality.
func FeaturePortsEqual ¶
func FeaturePortsEqual(a, b []*v1.FeaturePort) bool
FeaturePortsEqual compares two feature ports for equality.
func IsReservedPrefix ¶
IsReservedPrefix returns true if the given key is reserved.
func MeshNodesEqual ¶
MeshNodesEqual compares two mesh nodes for equality.
func ToPrefixes ¶
ToPrefixes converts a list of CIDRs to a list of Prefixes. It silently ignores invalid CIDRs.
func WireGuardPeerEqual ¶
func WireGuardPeerEqual(a, b *v1.WireGuardPeer) bool
WireGuardPeerEqual compares two WireGuard peers for equality.
func WireGuardPeersEqual ¶
func WireGuardPeersEqual(a, b []*v1.WireGuardPeer) bool
WireGuardPeersEqual recurses the WireGuard peers and compares them for equality. Both lists are sorted by ID first.
Types ¶
type AdjacencyMap ¶
AdjacencyMap is a map of node names to a map of node names to edges.
func NewAdjacencyMap ¶
func NewAdjacencyMap(g PeerGraph) (AdjacencyMap, error)
NewAdjacencyMap returns a new adjacency map for the graph.
func (AdjacencyMap) DeepEqual ¶
func (a AdjacencyMap) DeepEqual(b AdjacencyMap) bool
DeepEqual returns true if the given AdjacencyMap is equal to this AdjacencyMap.
type Edge ¶
Edge is the graph.Edge implementation for the mesh network.
func (Edge) ToMeshEdge ¶
ToMeshEdge converts an Edge to a MeshEdge.
type Group ¶ added in v0.9.2
Group wraps a group.
func (Group) DeepCopyInto ¶ added in v0.9.2
DeepCopyInto copies the node into the given group.
func (Group) MarshalJSON ¶ added in v0.9.2
MarshalJSON marshals the group to JSON.
func (*Group) UnmarshalJSON ¶ added in v0.9.2
UnmarshalJSON unmarshals the group from JSON.
type MeshEdge ¶
MeshEdge wraps a mesh edge.
func (MeshEdge) AsGraphEdge ¶
AsGraphEdge converts a MeshEdge to a graph.Edge.
func (MeshEdge) DeepCopyInto ¶ added in v0.9.4
DeepCopyInto copies the edge into the given edge.
func (MeshEdge) EdgeProperties ¶
func (e MeshEdge) EdgeProperties() graph.EdgeProperties
EdgeProperties returns the edge's properties.
func (MeshEdge) MarshalJSON ¶
MarshalJSON marshals a MeshEdge to JSON.
func (*MeshEdge) UnmarshalJSON ¶
UnmarshalJSON unmarshals a MeshEdge from JSON.
type MeshNode ¶
MeshNode wraps a mesh node.
func (MeshNode) DeepCopyInto ¶ added in v0.9.2
DeepCopyInto copies the node into the given node.
func (MeshNode) DeepEqual ¶ added in v0.9.2
DeepEqual returns true if the node is deeply equal to the given node.
func (MeshNode) HasFeature ¶
HasFeature returns true if the node has the given feature.
func (MeshNode) MarshalJSON ¶
MarshalJSON marshals the node to JSON.
func (MeshNode) PortFor ¶
PortFor returns the port for the given feature, or 0 if the feature is not available on this node.
func (MeshNode) PrivateAddrV4 ¶
PrivateAddrV4 returns the node's private IPv4 address. Be sure to check if the returned Addr IsValid.
func (MeshNode) PrivateAddrV6 ¶
PrivateAddrV6 returns the node's private IPv6 address. Be sure to check if the returned Addr IsValid.
func (MeshNode) PrivateDNSAddrV4 ¶
PrivateDNSAddrV4 returns the private IPv4 address for the node's DNS server. Be sure to check if the returned AddrPort IsValid.
func (MeshNode) PrivateDNSAddrV6 ¶
PrivateDNSAddrV6 returns the private IPv6 address for the node's DNS server. Be sure to check if the returned AddrPort IsValid.
func (MeshNode) PrivateRPCAddrV4 ¶
PrivateRPCAddrV4 returns the private IPv4 address for the node's RPC server. Be sure to check if the returned AddrPort IsValid.
func (MeshNode) PrivateRPCAddrV6 ¶
PrivateRPCAddrV6 returns the private IPv6 address for the node's RPC server. Be sure to check if the returned AddrPort IsValid.
func (MeshNode) PrivateStorageAddrV4 ¶
PrivateStorageAddrV4 returns the private IPv4 address for the node's raft listener. Be sure to check if the returned AddrPort IsValid.
func (MeshNode) PrivateStorageAddrV6 ¶
PrivateStorageAddrV6 returns the private IPv6 address for the node's raft listener. Be sure to check if the returned AddrPort IsValid.
func (MeshNode) PrivateTURNAddrV4 ¶
PrivateTURNAddrV4 returns the private IPv4 address for the node's TURN server. Be sure to check if the returned AddrPort IsValid.
func (MeshNode) PrivateTURNAddrV6 ¶
PrivateTURNAddrV6 returns the private IPv6 address for the node's TURN server. Be sure to check if the returned AddrPort IsValid.
func (MeshNode) PublicDNSAddr ¶
PublicDNSAddr returns the public address for the node's DNS server. Be sure to check if the returned AddrPort IsValid.
func (MeshNode) PublicRPCAddr ¶
PublicRPCAddr returns the public address for the node's RPC server. Be sure to check if the returned AddrPort IsValid.
func (MeshNode) StoragePort ¶
StoragePort returns the node's Storage port.
func (*MeshNode) UnmarshalJSON ¶
UnmarshalJSON unmarshals the node from JSON.
type NetworkACL ¶
type NetworkACL struct {
*v1.NetworkACL `json:",inline"`
}
NetworkACL is a Network ACL.
func (NetworkACL) DeepCopy ¶ added in v0.9.2
func (n NetworkACL) DeepCopy() NetworkACL
DeepCopy returns a deep copy of the network ACL.
func (NetworkACL) DeepCopyInto ¶ added in v0.9.2
func (n NetworkACL) DeepCopyInto(acl *NetworkACL)
DeepCopyInto copies the node into the given acl.
func (NetworkACL) DestinationPrefixes ¶
func (a NetworkACL) DestinationPrefixes() []netip.Prefix
DestinationPrefixes returns the destination prefixes for the ACL. Invalid prefixes will be ignored.
func (NetworkACL) Equals ¶
func (a NetworkACL) Equals(other NetworkACL) bool
Equals returns whether the ACLs are equal.
func (NetworkACL) MarshalJSON ¶
func (a NetworkACL) MarshalJSON() ([]byte, error)
Marshal marshals the ACL to protobuf json.
func (NetworkACL) Matches ¶
func (acl NetworkACL) Matches(ctx context.Context, action NetworkAction) bool
Matches checks if an action matches this ACL.
func (NetworkACL) Proto ¶
func (a NetworkACL) Proto() *v1.NetworkACL
Proto returns the protobuf representation of the ACL.
func (NetworkACL) SourcePrefixes ¶
func (a NetworkACL) SourcePrefixes() []netip.Prefix
SourcePrefixes returns the source prefixes for the ACL. Invalid prefixes will be ignored.
func (*NetworkACL) UnmarshalJSON ¶
func (a *NetworkACL) UnmarshalJSON(data []byte) error
Unmarshal unmarshals the ACL from a protobuf.
type NetworkACLs ¶
type NetworkACLs []NetworkACL
ACLs is a list of Network ACLs. It contains methods for evaluating actions against contained permissions. It also allows for sorting by priority.
func (NetworkACLs) Accept ¶
func (a NetworkACLs) Accept(ctx context.Context, action NetworkAction) bool
Accept evaluates an action against the ACLs in the list. It assumes the ACLs are sorted by priority. The first ACL that matches the action will be used. If no ACL matches, the action is denied.
func (NetworkACLs) AllowNodesToCommunicate ¶
func (a NetworkACLs) AllowNodesToCommunicate(ctx context.Context, nodeA, nodeB MeshNode) bool
AllowNodesToCommunicate checks if the given nodes are allowed to communicate.
func (NetworkACLs) Less ¶
func (a NetworkACLs) Less(i, j int) bool
Less returns whether the ACL at index i should be sorted before the ACL at index j.
func (NetworkACLs) Proto ¶
func (a NetworkACLs) Proto() []*v1.NetworkACL
Proto returns the protobuf representation of the ACLs.
func (NetworkACLs) Sort ¶
func (a NetworkACLs) Sort(direction SortDirection)
Sort sorts the ACLs by priority.
func (NetworkACLs) Swap ¶
func (a NetworkACLs) Swap(i, j int)
Swap swaps the ACLs at the given indices.
type NetworkAction ¶
type NetworkAction struct {
*v1.NetworkAction `json:",inline"`
}
NetworkAction wraps a NetworkAction.
func (*NetworkAction) DestinationPrefix ¶
func (a *NetworkAction) DestinationPrefix() netip.Prefix
DestinationPrefix returns the destination prefix for the action if it is valid.
func (*NetworkAction) Proto ¶
func (a *NetworkAction) Proto() *v1.NetworkAction
Proto returns the protobuf representation of the action.
func (*NetworkAction) SourcePrefix ¶
func (a *NetworkAction) SourcePrefix() netip.Prefix
SourcePrefix returns the source prefix for the action if it is valid.
type NodeID ¶
type NodeID string
NodeID is the type of a node ID.
type PeerGraph ¶
PeerGraph is the graph.Graph implementation for the mesh network.
func NewGraphWithStore ¶
func NewGraphWithStore(store PeerGraphStore) PeerGraph
NewGraphWithStore creates a new Graph instance with the given graph storage implementation.
type PeerGraphStore ¶
PeerGraphStore is the graph.Store implementation for the mesh network.
type Prefix ¶
type Prefix []byte
Prefix is a prefix in the storage.
type Role ¶ added in v0.9.2
Role wraps a role.
func (Role) DeepCopyInto ¶ added in v0.9.2
DeepCopyInto copies the node into the given role.
func (Role) MarshalJSON ¶ added in v0.9.2
MarshalJSON marshals the role to JSON.
func (*Role) UnmarshalJSON ¶ added in v0.9.2
UnmarshalJSON unmarshals the role from JSON.
type RoleBinding ¶ added in v0.9.2
type RoleBinding struct {
*v1.RoleBinding `json:",inline"`
}
RoleBinding wraps a rolebinding.
func (RoleBinding) DeepCopy ¶ added in v0.9.2
func (n RoleBinding) DeepCopy() RoleBinding
DeepCopy returns a deep copy of the rolebinding.
func (RoleBinding) DeepCopyInto ¶ added in v0.9.2
func (n RoleBinding) DeepCopyInto(role *RoleBinding)
DeepCopyInto copies the node into the given rolebinding.
func (RoleBinding) MarshalJSON ¶ added in v0.9.2
func (n RoleBinding) MarshalJSON() ([]byte, error)
MarshalJSON marshals the rolebinding to JSON.
func (RoleBinding) Proto ¶ added in v0.9.2
func (n RoleBinding) Proto() *v1.RoleBinding
Proto returns the underlying protobuf.
func (*RoleBinding) UnmarshalJSON ¶ added in v0.9.2
func (n *RoleBinding) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals the rolebinding from JSON.
type RolesList ¶
type RolesList []Role
RolesList is a list of roles. It contains methods for evaluating actions against contained permissions.
type Route ¶
Route wraps a Route.
func (Route) DeepCopyInto ¶ added in v0.9.2
DeepCopyInto copies the node into the given route.
func (*Route) DestinationPrefixes ¶
DestinationPrefixes returns the destination prefixes for the route.
func (Route) MarshalJSON ¶
Marshal marshals the route to protobuf json.
func (*Route) UnmarshalJSON ¶
Unmarshal unmarshals the route from a protobuf.
type Routes ¶
type Routes []Route
Routes is a list of routes.
func (Routes) Less ¶
Less returns whether the name of the route at index i is less than the name of the route at index j.
type SortDirection ¶
type SortDirection int
SortDirection is the direction to sort ACLs.
const ( // SortDescending sorts ACLs in descending order. SortDescending SortDirection = iota // SortAscending sorts ACLs in ascending order. SortAscending )
type SortedWireGuardPeers ¶
type SortedWireGuardPeers []*v1.WireGuardPeer
SortedWireGuardPeers implements a sort.Interface for []*v1.WireGuardPeer.
func (SortedWireGuardPeers) Len ¶
func (s SortedWireGuardPeers) Len() int
func (SortedWireGuardPeers) Less ¶
func (s SortedWireGuardPeers) Less(i, j int) bool
func (SortedWireGuardPeers) Swap ¶
func (s SortedWireGuardPeers) Swap(i, j int)