util

package module
v0.0.0-...-2159e90 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2021 License: MIT Imports: 14 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecCommand

func ExecCommand(command string, logger *device.Logger) ([]byte, error)

func GetUapi

func GetUapi(iface string, logger *device.Logger, errs chan error) (*wgctrl.Client, *wgtypes.Device)

func ParseKey

func ParseKey(key string) (wgtypes.Key, error)

ParseKey parses the base64 encoded wireguard private key

Types

type IPPool

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

func NewIPPool

func NewIPPool(cidr string) (*IPPool, error)

func (*IPPool) CurrentIP

func (i *IPPool) CurrentIP() net.IP

func (*IPPool) CurrentIPMask

func (i *IPPool) CurrentIPMask() net.IPMask

func (*IPPool) GetStartingIP

func (i *IPPool) GetStartingIP() net.IP

func (*IPPool) IPNet

func (i *IPPool) IPNet() *net.IPNet

func (*IPPool) Next

func (i *IPPool) Next(logger *device.Logger) (net.IP, error)

type WGPool

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

func NewWGPool

func NewWGPool(iface string, logger *device.Logger, errs chan error) *WGPool

func (*WGPool) AddPoolPeer

func (w *WGPool) AddPoolPeer(subdomain string, publicKey wgtypes.Key, ipAddress net.IP)

func (*WGPool) AddPoolPeerByPubKey

func (w *WGPool) AddPoolPeerByPubKey(publicKey wgtypes.Key)

func (*WGPool) CleanUpStalePeers

func (w *WGPool) CleanUpStalePeers(keepAliveDuration time.Duration, onStaleF onStale)

func (*WGPool) GetPeerAddressBySubdomain

func (w *WGPool) GetPeerAddressBySubdomain(subdomain string) net.IP

func (*WGPool) GetPoolPeerByPubKey

func (w *WGPool) GetPoolPeerByPubKey(pubkey wgtypes.Key) *WGPoolPeer

func (*WGPool) HasSubdomain

func (w *WGPool) HasSubdomain(subdomain string) bool

type WGPoolPeer

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

func (*WGPoolPeer) PublicKey

func (W *WGPoolPeer) PublicKey() wgtypes.Key

type WgQuickConfig

type WgQuickConfig struct {
	wgtypes.Config

	// Address list of IP (v4 or v6) addresses (optionally with CIDR masks) to be assigned to the interface. May be specified multiple times.
	Address []net.IPNet

	// list of IP (v4 or v6) addresses to be set as the interface’s DNS servers. May be specified multiple times. Upon bringing the interface up, this runs ‘resolvconf -a tun.INTERFACE -m 0 -x‘ and upon bringing it down, this runs ‘resolvconf -d tun.INTERFACE‘. If these particular invocations of resolvconf(8) are undesirable, the PostUp and PostDown keys below may be used instead.
	DNS []net.IP

	// MTU is automatically determined from the endpoint addresses or the system default route, which is usually a sane choice. However, to manually specify an MTU to override this automatic discovery, this value may be specified explicitly.
	MTU int

	// Table — Controls the routing table to which routes are added.
	Table int

	// PreUp, PostUp, PreDown, PostDown — script snippets which will be executed by bash(1) before/after setting up/tearing down the interface, most commonly used to configure custom DNS options or firewall rules. The special string ‘%i’ is expanded to INTERFACE. Each one may be specified multiple times, in which case the commands are executed in order.
	PreUp    string
	PostUp   string
	PreDown  string
	PostDown string

	// RouteProtocol to set on the route. See linux/rtnetlink.h  Use value > 4 or default 0
	RouteProtocol int

	// RouteMetric sets this metric on all managed routes. Lower number means pick this one
	RouteMetric int

	// Address label to set on the link
	AddressLabel string

	// SaveConfig — if set to ‘true’, the configuration is saved from the current state of the interface upon shutdown.
	// Currently unsupported
	SaveConfig bool
}

WgQuickConfig represents full wg-quick like config structure

func (*WgQuickConfig) MarshalText

func (cfg *WgQuickConfig) MarshalText() (text []byte, err error)

func (*WgQuickConfig) String

func (cfg *WgQuickConfig) String() string

func (*WgQuickConfig) UnmarshalText

func (cfg *WgQuickConfig) UnmarshalText(text []byte) error

Jump to

Keyboard shortcuts

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