lib

package
v0.0.0-...-e26558c Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2024 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const IP_SERVICE = "https://api.ipify.org?format=json"
View Source
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 Contains

func Contains[V any](list []V, proposition func(V) bool) bool

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

func GetOutboundIP() (net.IP, error)

GetOutboundIP: gets the oubound IP of this packet

func GetPublicIP

func GetPublicIP() (net.IP, error)

GetPublicIP: get the nodes public IP address. For when a node is behind NAT

func HashString

func HashString(value string) int

func Map

func Map[V1 any, V2 any](list []V1, f convert[V1, V2]) []V2

Map turns a list of type V1 into type V2

func MapKeys

func MapKeys[K cmp.Ordered, V any](m map[K]V) []K

func MapValues

func MapValues[K cmp.Ordered, V any](m map[K]V) []V

MapToSlice converts a map to a slice in go

func MapValuesWithExclude

func MapValuesWithExclude[K cmp.Ordered, V any](m map[K]V, exclude map[K]struct{}) []V

func MatchCaptureGroup

func MatchCaptureGroup(pattern, payload string) map[string]string

func RandomSubsetOfLength

func RandomSubsetOfLength[V any](vs []V, num int) []V

RandomSubsetOfLength: Given an array of nodes generate of random subset of 'num' length.

func Reduce

func Reduce[A any, V any](start A, values []V, reduce func(A, V) A) A

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 MapItemsEntry[K cmp.Ordered, V any] struct {
	Key   K
	Value V
}

func MapItems

func MapItems[K cmp.Ordered, V any](m map[K]V) []MapItemsEntry[K, V]

type Route

type Route struct {
	Gateway     net.IP
	Destination net.IPNet
}

route: represents a rout to add to the RIB

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 (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 (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 Timer

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

func NewTimer

func NewTimer(f TimerFunc, updateRate int) *Timer

func (*Timer) Run

func (t *Timer) Run() error

func (*Timer) Stop

func (t *Timer) Stop() error

type TimerFunc

type TimerFunc = func() error

type UUIDGenerator

type UUIDGenerator struct {
}

func (*UUIDGenerator) GetId

func (g *UUIDGenerator) GetId() (string, error)

Jump to

Keyboard shortcuts

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