Documentation
¶
Index ¶
- Constants
- func ConsistentHash[V any, K any](values []V, client K, bucketFunc func(V) int, keyFunc func(K) int) V
- func Contains[V any](list []V, proposition func(V) bool) bool
- func Filter[V any](list []V, f filterFunc[V]) []V
- func GetOutboundIP() (net.IP, error)
- func GetPublicIP() (net.IP, error)
- func HashString(value string) int
- func Map[V1 any, V2 any](list []V1, f convert[V1, V2]) []V2
- func MapKeys[K cmp.Ordered, V any](m map[K]V) []K
- func MapValues[K cmp.Ordered, V any](m map[K]V) []V
- func MapValuesWithExclude[K cmp.Ordered, V any](m map[K]V, exclude map[K]struct{}) []V
- func MatchCaptureGroup(pattern, payload string) map[string]string
- func RandomSubsetOfLength[V any](vs []V, num int) []V
- func Reduce[A any, V any](start A, values []V, reduce func(A, V) A) A
- type IDNameGenerator
- type IdGenerator
- type IpResponse
- type MapItemsEntry
- type Route
- type RtNetlinkConfig
- func (c *RtNetlinkConfig) AddAddress(ifName string, address string) error
- func (c *RtNetlinkConfig) AddRoute(ifName string, route Route) error
- func (c *RtNetlinkConfig) Close() error
- func (c *RtNetlinkConfig) CreateLink(ifName string) error
- func (c *RtNetlinkConfig) DeleteLink(ifName string) error
- func (c *RtNetlinkConfig) DeleteRoute(ifName string, route Route) error
- func (c *RtNetlinkConfig) DeleteRoutes(ifName string, family uint8, exclude ...Route) error
- type ShortIDGenerator
- type Timer
- type TimerFunc
- type UUIDGenerator
Constants ¶
const IP_SERVICE = "https://api.ipify.org?format=json"
const WIREGUARD_MTU = 1420
Maximum MTU to assin to WireGuard This isn't configurable
Variables ¶
This section is empty.
Functions ¶
func ConsistentHash ¶
func ConsistentHash[V any, K any](values []V, client K, bucketFunc func(V) int, keyFunc func(K) int) V
ConsistentHash implementation. Traverse the values until we find a key greater than ours.
func Filter ¶
func Filter[V any](list []V, f filterFunc[V]) []V
Filter filters out elements given a filter function. If filter function is true keep it in otherwise leave it out
func GetOutboundIP ¶
GetOutboundIP: gets the oubound IP of this packet
func GetPublicIP ¶
GetPublicIP: get the nodes public IP address. For when a node is behind NAT
func HashString ¶
func MapValuesWithExclude ¶
func MatchCaptureGroup ¶
func RandomSubsetOfLength ¶
RandomSubsetOfLength: Given an array of nodes generate of random subset of 'num' length.
Types ¶
type IDNameGenerator ¶
type IDNameGenerator struct { }
func (*IDNameGenerator) GetId ¶
func (i *IDNameGenerator) GetId() (string, error)
type IdGenerator ¶
type IdGenerator interface { // GetId generates a unique ID or an error if something went wrong GetId() (string, error) }
IdGenerator generates unique ids
type IpResponse ¶
type IpResponse struct {
Ip string `json:"ip"`
}
func (*IpResponse) GetIP ¶
func (i *IpResponse) GetIP() net.IP
type MapItemsEntry ¶
type RtNetlinkConfig ¶
type RtNetlinkConfig struct {
// contains filtered or unexported fields
}
RtNetlinkConfig: represents an rtnetlkink configuration instance
func NewRtNetlinkConfig ¶
func NewRtNetlinkConfig() (*RtNetlinkConfig, error)
newRtNetlinkConfig: connect to the RtnetlinkAPI
func (*RtNetlinkConfig) AddAddress ¶
func (c *RtNetlinkConfig) AddAddress(ifName string, address string) error
AddAddress: adds an address to the given interface.
func (*RtNetlinkConfig) AddRoute ¶
func (c *RtNetlinkConfig) AddRoute(ifName string, route Route) error
AddRoute: adds a route to the routing table. ifName is the intrface to add the route to gateway is the IP of the gateway device to hop to dst is the network prefix of the advertised destination
func (*RtNetlinkConfig) Close ¶
func (c *RtNetlinkConfig) Close() error
Close: close the Rtnetlink API
func (*RtNetlinkConfig) CreateLink ¶
func (c *RtNetlinkConfig) CreateLink(ifName string) error
CreateLink: Create a netlink interface if it does not exist. ifName is the name of the netlink interface
func (*RtNetlinkConfig) DeleteLink ¶
func (c *RtNetlinkConfig) DeleteLink(ifName string) error
DeleteLink: delete the specified interface
func (*RtNetlinkConfig) DeleteRoute ¶
func (c *RtNetlinkConfig) DeleteRoute(ifName string, route Route) error
DeleteRoute: deletes routes with the gateway and destination
func (*RtNetlinkConfig) DeleteRoutes ¶
func (c *RtNetlinkConfig) DeleteRoutes(ifName string, family uint8, exclude ...Route) error
DeleteRoutes: deletes all routes not in exclude on the given interface
type ShortIDGenerator ¶
type ShortIDGenerator struct { }
func (*ShortIDGenerator) GetId ¶
func (g *ShortIDGenerator) GetId() (string, error)
type UUIDGenerator ¶
type UUIDGenerator struct { }
func (*UUIDGenerator) GetId ¶
func (g *UUIDGenerator) GetId() (string, error)