Documentation
¶
Overview ¶
Package functions provides netclient logic
Index ¶
- Constants
- Variables
- func Authenticate(server *config.Server, host *config.Config) (string, error)
- func BoxDecrypt(encrypted []byte, senderPublicKey *[32]byte, recipientPrivateKey *[32]byte) ([]byte, error)
- func BoxEncrypt(message []byte, recipientPubKey *[32]byte, senderPrivateKey *[32]byte) ([]byte, error)
- func ChangeProxyStatus(status bool) error
- func Checkin(ctx context.Context, wg *sync.WaitGroup)
- func Chunk(message []byte, recipientPubKey *[32]byte, senderPrivateKey *[32]byte) ([]byte, error)
- func Connect(network string) error
- func Daemon()
- func DeChunk(chunkedMsg []byte, senderPublicKey *[32]byte, recipientPrivateKey *[32]byte) ([]byte, error)
- func Disconnect(network string) error
- func GetLocalListenPort(ifacename string) (int, error)
- func GetNodePeers(node config.Node) ([]wgtypes.PeerConfig, error)
- func Hello(node *config.Node)
- func HostPeerUpdate(client mqtt.Client, msg mqtt.Message)
- func HostUpdate(client mqtt.Client, msg mqtt.Message)
- func Install() error
- func IsVersionComptatible(ver string) bool
- func Join(flags *viper.Viper) error
- func JoinNetwork(flags *viper.Viper) (*config.Node, *config.Server, error)
- func JoinViaSSo(flags *viper.Viper) (*models.AccessToken, error)
- func LeaveNetwork(network string, isDaemon bool) ([]error, error)
- func List(net string, long bool)
- func Migrate()
- func NodeUpdate(client mqtt.Client, msg mqtt.Message)
- func PublishGlobalHostUpdate(hostAction models.HostMqAction) error
- func PublishHostUpdate(server string, hostAction models.HostMqAction) error
- func PublishNodeUpdate(node *config.Node) error
- func Pull(network string, iface bool) (*config.Node, error)
- func Register(token string) error
- func RemoveServer(node *config.Node)
- func SelfUpdate(currentVersion string, rebootDaemon bool)
- func Uninstall() ([]error, error)
- func UpdateHostSettings() error
- func UpdateKeys(node *config.Node, host *config.Config, client mqtt.Client) error
- func UseVersion(version string, rebootDaemon bool) error
Constants ¶
const ( // ACK - acknowledgement signal for MQ ACK = 1 // DONE - done signal for MQ DONE = 2 // CheckInInterval - interval in minutes for mq checkins CheckInInterval = 1 )
const MQTimeout = 30
MQTimeout - time out for mqtt connections
const MinVersion = "v0.18.0"
Variables ¶
var All mqtt.MessageHandler = func(client mqtt.Client, msg mqtt.Message) { logger.Log(0, "default message handler -- received message but not handling") logger.Log(0, "topic: "+string(msg.Topic())) }
All -- mqtt message hander for all ('#') topics
var ProxyManagerChan = make(chan *models.HostPeerUpdate, 50)
var ServerSet = make(map[string]mqtt.Client)
Functions ¶
func Authenticate ¶
Authenticate authenticates with netmaker api to permit subsequent interactions with the api
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 ChangeProxyStatus ¶
ChangeProxyStatus - updates proxy status on host and publishes global host update
func Checkin ¶
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 DeChunk ¶
func DeChunk(chunkedMsg []byte, senderPublicKey *[32]byte, recipientPrivateKey *[32]byte) ([]byte, error)
DeChunk - "de" chunks and decrypts a message
func Disconnect ¶
Disconnect disconnects a node from the given network
func GetLocalListenPort ¶
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 ¶
HostPeerUpdate - mq handler for host peer update peers/host/<HOSTID>/<SERVERNAME>
func HostUpdate ¶
HostUpdate - mq handler for host update host/update/<HOSTID>/<SERVERNAME>
func IsVersionComptatible ¶
IsVersionCompatible checks that the version passed is compabtible (>=) with MinVersion
func JoinNetwork ¶
JoinNetwork - connects to netmaker server to join a network
func JoinViaSSo ¶
func JoinViaSSo(flags *viper.Viper) (*models.AccessToken, error)
JoinViaSSo - Handles the Single Sign-On flow on the end point VPN client side Contacts the server provided by the user (and thus specified in cfg.SsoServer) get the URL to authenticate with a provider and shows the user the URL. Then waits for user to authenticate with the URL. Upon user successful auth flow finished - server should return access token to the requested network Otherwise the error message is sent which can be displayed to the user
func LeaveNetwork ¶
LeaveNetwork - client exits a network
func List ¶
List - list network details for specified networks long flag passed passed to cmd line will list additional details about network including peers
func Migrate ¶
func Migrate()
Migrate update data from older versions of netclient to new format TODO fix it
func NodeUpdate ¶
NodeUpdate -- mqtt message handler for /update/<NodeID> topic
func PublishGlobalHostUpdate ¶
func PublishGlobalHostUpdate(hostAction models.HostMqAction) error
PublishGlobalHostUpdate - publishes host updates to all the servers host is registered.
func PublishHostUpdate ¶
func PublishHostUpdate(server string, hostAction models.HostMqAction) error
PublishHostUpdate - publishes host updates to server
func PublishNodeUpdate ¶
PublishNodeUpdate -- pushes node to broker
func RemoveServer ¶
RemoveServer - removes a server from server conf given a specific node
func SelfUpdate ¶
SelfUpdate updates the netclient binary in place to the latest release available on GitHub and reboots the daemon if update is successful All binary names must adhere to the format `netclient-{platform}-{architecture}`
func UpdateHostSettings ¶
func UpdateHostSettings() error
UpdateHostSettings - checks local host settings, if different, mod config and publish
func UpdateKeys ¶
UpdateKeys -- updates private key and returns new publickey
func UseVersion ¶
UseVersion switches the current netclient version to the one specified if available in the github releases page
Types ¶
This section is empty.