Documentation
¶
Index ¶
- Constants
- Variables
- 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 CheckEgressDomainUpdates()
- 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 DNSSync(client mqtt.Client, msg mqtt.Message)
- func Daemon()
- func DeChunk(chunkedMsg []byte, senderPublicKey *[32]byte, recipientPrivateKey *[32]byte) ([]byte, error)
- func Disconnect(network string) error
- func FilterDnsNameservers(nameservers []models.Nameserver) []models.Nameserver
- func GetLocalListenPort(ifacename string) (int, error)
- func GetNodePeers(node config.Node) ([]wgtypes.PeerConfig, error)
- func GetPublicIP(proto uint) (net.IP, error)
- func HostPeerUpdate(client mqtt.Client, msg mqtt.Message)
- func HostUpdate(client mqtt.Client, msg mqtt.Message)
- func Install() error
- func IsContainerized() bool
- func IsVersionComptatible(ver string) bool
- func LeaveNetwork(network string, isDaemon bool) ([]error, error)
- func LeaveServer(s string) error
- func List(net string, long bool)
- func ListServers() error
- func NodeUpdate(client mqtt.Client, msg mqtt.Message)
- func PingPeers(networkFilter, peerFilter string, jsonOutput bool, packetCount int, ...) error
- func PostureStatus(jsonOutput bool) (int, error)
- func PublishHostUpdate(server string, hostAction models.HostMqAction) error
- func PublishNodeUpdate(node *config.Node) error
- func Pull(restart bool, resetIfFailedOvered bool) (models.HostPull, bool, bool, error)
- func Push(restart bool) error
- func Register(token string) error
- func RegisterWithSSO(registerData *RegisterSSO) (err error)
- func ShowPeers(jsonOutput bool, networkFilter string) error
- func SignalPeer(signal models.Signal) error
- func StartEgressDomainMonitor(ctx context.Context, wg *sync.WaitGroup)
- func StopAllTCPUplink()
- func SwitchServer(server string) error
- func Uninstall() ([]error, error)
- func UpdateHostFromServer(host *schema.Host) (resetInterface, restart, sendHostUpdate bool)
- func UpdateHostSettings(fallback bool) error
- func UpdateKeys() error
- func UseVersion(version string, rebootDaemon bool) (skip bool, err error)
- type PingResult
- type RegisterSSO
Constants ¶
const ( TestIPv4 = "1.1.1.1" TestIPv6 = "2606:4700:4700::1111" )
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 MDMDeniedMessage = "Access blocked: this device is not enrolled or compliant in your organization MDM."
MDMDeniedMessage is the exact string netclient prints when the server refuses access because the host is not enrolled or compliant in the organization MDM. Wording is part of the user-facing contract.
const MQTimeout = 30
MQTimeout - time out for mqtt connections
const (
// MQ_TIMEOUT - timeout for MQ
MQ_TIMEOUT = 30
)
const MinVersion = "v0.18.0"
Variables ¶
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
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 CheckEgressDomainUpdates ¶ added in v1.1.0
func CheckEgressDomainUpdates()
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 DNSSync ¶ added in v0.26.0
DNSSync -- mqtt message handler for host/dns/sync/<network id> topic
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 FilterDnsNameservers ¶ added in v1.2.0
func FilterDnsNameservers(nameservers []models.Nameserver) []models.Nameserver
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 IsContainerized ¶ added in v1.5.1
func IsContainerized() bool
IsContainerized returns true if the process appears to be running inside a Docker container, Kubernetes pod, or other containerd-based runtime.
func IsVersionComptatible ¶
IsVersionCompatible checks that the version passed is compabtible (>=) with MinVersion
func LeaveNetwork ¶
LeaveNetwork - client exits a network
func LeaveServer ¶ added in v0.21.0
LeaveServer - leave the named server
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 ListServers ¶ added in v0.21.0
func ListServers() error
ListServers - lists all registered servers
func NodeUpdate ¶
NodeUpdate -- mqtt message handler for /update/<NodeID> topic
func PingPeers ¶ added in v1.4.0
func PingPeers(networkFilter, peerFilter string, jsonOutput bool, packetCount int, ipVersion string) error
PingPeers checks connectivity to peers and displays status and latency. If networkFilter is non-empty, only peers in that network are considered. If peerFilter is non-empty, only peers whose name, address, or ID match (case-insensitive) are considered. packetCount controls how many packets/probes are sent per peer (<=0 uses a sensible default). ipVersion can be "4" for IPv4, "6" for IPv6, or "" for default address.
func PostureStatus ¶ added in v1.7.0
PostureStatus calls GET /api/v1/host/{hostid}/posture_status on the current server, renders the result, and returns a suggested process exit code.
Exit codes:
0 - all networks pass 1 - one or more networks have status=fail 2 - transport/auth error or MDM denial
On MDM denial (server returns the well-known sentinel error) the standard user-facing message is printed to stderr.
func PublishHostUpdate ¶
func PublishHostUpdate(server string, hostAction models.HostMqAction) error
PublishHostUpdate - publishes host updates to server
func PublishNodeUpdate ¶
PublishNodeUpdate -- pushes node to broker
func RegisterWithSSO ¶ added in v0.18.7
func RegisterWithSSO(registerData *RegisterSSO) (err error)
RegisterWithSSO - register with user credentials with a netmaker server
func ShowPeers ¶ added in v1.4.0
ShowPeers displays peer information from the WireGuard interface, grouped per network. If networkFilter is non-empty, only that network's peers are displayed.
func SignalPeer ¶ added in v0.22.0
SignalPeer - signals the peer with host's turn relay endpoint
func StartEgressDomainMonitor ¶ added in v1.6.0
StartEgressDomainMonitor periodically re-resolves egress domains on the egress gateway node.
func StopAllTCPUplink ¶ added in v1.7.0
func StopAllTCPUplink()
StopAllTCPUplink tears down client/server sessions and drains async Bind sends. Must run before userspace Device.Close / iface recreate (disable, SIGHUP, shutdown).
func SwitchServer ¶ added in v0.20.2
SwitchServer - switches netclient server context
func UpdateHostFromServer ¶ added in v1.7.0
UpdateHostFromServer merges a server host payload into local config. Posture identity fields are never taken from the server; they are restored from local config and then refreshed from the machine.
func UpdateHostSettings ¶
UpdateHostSettings - checks local host settings, if different, mod config and publish
func UpdateKeys ¶
func UpdateKeys() error
UpdateKeys -- updates private key and returns new publickey
Types ¶
type PingResult ¶ added in v1.4.0
type PingResult struct {
Network string `json:"network"`
Name string `json:"name"`
Address string `json:"address"`
IsExt bool `json:"is_extclient"`
Connected bool `json:"connected"`
LatencyMs int64 `json:"latency_ms"`
UserName string `json:"username,omitempty"`
}
PingResult holds the result of a single peer connectivity check