Documentation
¶
Index ¶
- Variables
- func ApplyDesiredConnectedFlags()
- func CancelDeviceNetworkJoinOnServer(network, token string) error
- func ConnectNetwork(network, server, token string) error
- func DropNetworkExitSelection(network, token string) error
- func FetchDeviceNetworks(server, token string) ([]models.DeviceNetwork, error)
- func GetDeviceSelectedExitNode(network, token string) (*models.DeviceExitNode, error)
- func IsRegisteredToServer(server string) bool
- func JoinDeviceNetworkOnServer(network, token string) (string, error)
- func LeaveDeviceNetworkOnServer(network, token string) error
- func ListDeviceExitNodes(network, token string) ([]models.DeviceExitNode, error)
- func ListDeviceExitNodesForUI(network, token string) ([]models.DeviceExitNode, error)
- func NetworkRequiresAutoExit(network, server, token string) (bool, error)
- func RegisterDeviceOnServer(server, token string) error
- func RegisterSession(server, username, authToken, password, tenantID string) error
- func ReleaseSession(clearServer bool, unregisterHost bool) error
- func RequestJITOnServer(network, token, reason string) error
- func RestoreDesiredConnections(username, tenantID string) error
- func SelectDeviceExitNode(network, token, egressID string) (*models.DeviceExitNode, error)
- func SelectNearestDeviceExitNode(network, token string) (*models.DeviceExitNode, error)
- func SyncDeviceWithServer(token string) error
Constants ¶
This section is empty.
Variables ¶
var ErrApprovalPending = errors.New("host approval pending for network")
ErrApprovalPending is returned when a join request is awaiting admin approval.
var ErrApprovalRequired = errors.New("host approval required for network")
ErrApprovalRequired is returned when the user must request join before connecting.
var ErrDeviceBlocked = errors.New("access blocked: this device doesn't meet security requirements")
ErrDeviceBlocked is returned when posture checks block network access.
var ErrJITAccessRequired = errors.New("JIT access required: please request access from network admin")
ErrJITAccessRequired is returned when connect/join is blocked pending JIT approval.
var ErrNetworkNotConnected = errors.New("connect to the network before choosing an exit node")
ErrNetworkNotConnected is returned when exit list/select runs before the network is connected. Overlay VPN probes are the only ranking signal, so the mesh has to be up first.
Functions ¶
func ApplyDesiredConnectedFlags ¶
func ApplyDesiredConnectedFlags()
ApplyDesiredConnectedFlags sets node.Connected from persisted desired state without restarting. Call after Pull and before building the WireGuard iface so reboot / daemon reset comes up on the last connected networks.
func CancelDeviceNetworkJoinOnServer ¶
CancelDeviceNetworkJoinOnServer cancels a pending join approval request.
func ConnectNetwork ¶
ConnectNetwork joins (if needed) then connects locally.
func DropNetworkExitSelection ¶
DropNetworkExitSelection clears the server exit on one network and leaves the saved exit for any other network in place.
func FetchDeviceNetworks ¶
func FetchDeviceNetworks(server, token string) ([]models.DeviceNetwork, error)
FetchDeviceNetworks returns networks visible to the user from the server device API.
func GetDeviceSelectedExitNode ¶
func GetDeviceSelectedExitNode(network, token string) (*models.DeviceExitNode, error)
GetDeviceSelectedExitNode returns the currently selected exit node, or nil if none. The network must be connected so health/latency come from the overlay probe.
func IsRegisteredToServer ¶
IsRegisteredToServer reports whether netclient is fully registered to the given server. Partial Settings entries (API only, empty Server and TenantID) do not count; classic enrollments with Server set but empty TenantID do.
func JoinDeviceNetworkOnServer ¶
JoinDeviceNetworkOnServer registers the host on a network via the device API. Returns join status: "joined".
func LeaveDeviceNetworkOnServer ¶
LeaveDeviceNetworkOnServer removes the host from a network via the device API.
func ListDeviceExitNodes ¶
func ListDeviceExitNodes(network, token string) ([]models.DeviceExitNode, error)
ListDeviceExitNodes returns internet egress exit nodes available to this device on the network. The network must be connected so exits can be ranked by overlay VPN probes.
func ListDeviceExitNodesForUI ¶
func ListDeviceExitNodesForUI(network, token string) ([]models.DeviceExitNode, error)
ListDeviceExitNodesForUI returns exit nodes for the desktop selector. With an active session it may run while disconnected so the GUI can show the restored exit name after logout/login; overlay latency probes still require a live mesh.
func NetworkRequiresAutoExit ¶
NetworkRequiresAutoExit reports whether the network forces auto exit selection.
func RegisterDeviceOnServer ¶
RegisterDeviceOnServer registers the host via the device REST API using a user JWT.
func RegisterSession ¶
RegisterSession registers or refreshes a desktop UI session against a server. password is ignored (legacy desktop clients may still send it); authToken must be the user JWT. tenantID may be empty for classic non-MSP on-prem; MSP/SaaS should pass the workspace tenant.
func ReleaseSession ¶
ReleaseSession disconnects all networks and optionally clears server context. Currently connected networks (and exit selection) are saved so the next login can restore them. Local default routes are restored before disconnect so logout does not wait on a daemon restart for internet to return.
When unregisterHost is true (user/tenant handoff on PUT /session only), DELETE the host under the current session JWT after local disconnect. That lets a different user or MSP tenant enroll this machine next. Normal logout must pass unregisterHost=false so the same user can re-login without re-enrolling.
func RequestJITOnServer ¶
RequestJITOnServer submits a JIT access request via the server user JIT API.
func RestoreDesiredConnections ¶
RestoreDesiredConnections reconnects networks this user last had connected. Used after desktop login. Restarts the daemon once if anything changes.
func SelectDeviceExitNode ¶
func SelectDeviceExitNode(network, token, egressID string) (*models.DeviceExitNode, error)
SelectDeviceExitNode selects or clears (empty egressID) the exit node for the device. Switching A→B is not done in one step: clear first (None), then assign. The server rejects a direct switch while RelayedBy still points at the current gateway. Peer/IGW routes are applied by the MQTT peer update; we do not pull here. Selecting an exit requires the network to be connected. Clearing is always allowed.
func SelectNearestDeviceExitNode ¶
func SelectNearestDeviceExitNode(network, token string) (*models.DeviceExitNode, error)
SelectNearestDeviceExitNode lists exits, picks the nearest available one, and selects it. Persists auto_exit so session restore re-picks nearest rather than a fixed egress id. Switching A→B clears the current selection first (server rejects direct switch). Requires the network to be connected so ranking uses overlay VPN probes.
Waits for ExitOverlayProbeGrace after connect so latency samples are stable. Without this, UI Auto / enforced auto right after tunnel setup ranks on deferred or inflated RTTs and picks the wrong exit.
func SyncDeviceWithServer ¶
SyncDeviceWithServer pulls host config (reset auto-relay + refresh peer cache) and applies it in-process. Peers are always replaced so tray Sync fully reconfigures WireGuard without a daemon restart.
Types ¶
This section is empty.