functions

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: Apache-2.0 Imports: 49 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TestIPv4 = "1.1.1.1"
	TestIPv6 = "2606:4700:4700::1111"
)
View Source
const (
	// ACK - acknowledgement signal for MQ
	ACK = 1
	// DONE - done signal for MQ
	DONE = 2
	// CheckInInterval - interval in minutes for mq checkins
	CheckInInterval = 1
)
View Source
const MQTimeout = 30

MQTimeout - time out for mqtt connections

View Source
const (

	// MQ_TIMEOUT - timeout for MQ
	MQ_TIMEOUT = 30
)
View Source
const MinVersion = "v0.18.0"

Variables

View Source
var All mqtt.MessageHandler = func(client mqtt.Client, msg mqtt.Message) {
	slog.Info("default message handler -- received message but not handling", "topic", msg.Topic())
}

All -- mqtt message hander for all ('#') topics

View Source
var (

	// LastHandShakeThreshold - threshold for considering inactive connection
	LastHandShakeThreshold = time.Minute * 3
)
View Source
var (
	Mqclient mqtt.Client
)

Functions

func BoxDecrypt

func BoxDecrypt(encrypted []byte, senderPublicKey *[32]byte, recipientPrivateKey *[32]byte) ([]byte, error)

BoxDecrypt - decrypts traffic box

func BoxEncrypt

func BoxEncrypt(message []byte, recipientPubKey *[32]byte, senderPrivateKey *[32]byte) ([]byte, error)

BoxEncrypt - encrypts traffic box

func Checkin

func Checkin(ctx context.Context, wg *sync.WaitGroup)

Checkin -- go routine that checks for public or local ip changes, publishes changes

if there are no updates, simply "pings" the server as a checkin

func Chunk

func Chunk(message []byte, recipientPubKey *[32]byte, senderPrivateKey *[32]byte) ([]byte, error)

Chunk - chunks a message and encrypts each chunk

func Connect

func Connect(network string) error

Connect will attempt to connect a node on given network

func Daemon

func Daemon()

Daemon runs netclient daemon

func DeChunk

func DeChunk(chunkedMsg []byte, senderPublicKey *[32]byte, recipientPrivateKey *[32]byte) ([]byte, error)

DeChunk - "de" chunks and decrypts a message

func Disconnect

func Disconnect(network string) error

Disconnect disconnects a node from the given network

func GetLocalListenPort

func GetLocalListenPort(ifacename string) (int, error)

GetLocalListenPort - Gets the port running on the local interface

func GetNodePeers

func GetNodePeers(node config.Node) ([]wgtypes.PeerConfig, error)

GetNodePeers returns the peers for a given node

func HostPeerUpdate

func HostPeerUpdate(client mqtt.Client, msg mqtt.Message)

HostPeerUpdate - mq handler for host peer update peers/host/<HOSTID>/<SERVERNAME>

func HostUpdate

func HostUpdate(client mqtt.Client, msg mqtt.Message)

HostUpdate - mq handler for host update host/update/<HOSTID>/<SERVERNAME>

func Install

func Install() error

Install - installs binary/daemon

func IsVersionComptatible

func IsVersionComptatible(ver string) bool

IsVersionCompatible checks that the version passed is compabtible (>=) with MinVersion

func LeaveNetwork

func LeaveNetwork(network string, isDaemon bool) ([]error, error)

LeaveNetwork - client exits a network

func LeaveServer added in v0.21.0

func LeaveServer(s string) error

LeaveServer - leave the named server

func List

func List(net string, long bool)

List - list network details for specified networks long flag passed passed to cmd line will list additional details about network including peers

func ListServers added in v0.21.0

func ListServers() error

ListServers - lists all registered servers

func Migrate

func Migrate()

Migrate update data from older versions of netclient to new format

func NodeUpdate

func NodeUpdate(client mqtt.Client, msg mqtt.Message)

NodeUpdate -- mqtt message handler for /update/<NodeID> topic

func PublishHostUpdate

func PublishHostUpdate(server string, hostAction models.HostMqAction) error

PublishHostUpdate - publishes host updates to server

func PublishNodeUpdate

func PublishNodeUpdate(node *config.Node) error

PublishNodeUpdate -- pushes node to broker

func Pull

func Pull(restart bool) (models.HostPull, bool, bool, error)

Pull - pulls the latest config from the server, if manual it will overwrite

func Push added in v0.21.1

func Push(restart bool) error

Push - updates server with new host config

func Register added in v0.18.2

func Register(token string) error

Register - should be simple to register with a token

func RegisterWithSSO added in v0.18.7

func RegisterWithSSO(registerData *RegisterSSO) (err error)

RegisterWithSSO - register with user credentials with a netmaker server

func SignalPeer added in v0.22.0

func SignalPeer(signal models.Signal) error

SignalPeer - signals the peer with host's turn relay endpoint

func SwitchServer added in v0.20.2

func SwitchServer(server string) error

SwitchServer - switches netclient server context

func Uninstall

func Uninstall() ([]error, error)

Uninstall - uninstalls networks from client

func UpdateHostSettings

func UpdateHostSettings(fallback bool) error

UpdateHostSettings - checks local host settings, if different, mod config and publish

func UpdateKeys

func UpdateKeys() error

UpdateKeys -- updates private key and returns new publickey

func UseVersion

func UseVersion(version string, rebootDaemon bool) error

UseVersion switches the current netclient version to the one specified if available in the github releases page

Types

type RegisterSSO added in v0.18.7

type RegisterSSO struct {
	API         string
	User        string
	Pass        string
	Network     string
	UsingSSO    bool
	AllNetworks bool
}

RegisterSSO - payload to register via SSO

Jump to

Keyboard shortcuts

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