Documentation
¶
Overview ¶
Package netbird provides a small, read-only view of the local NetBird daemon's state. It shells out to `netbird status --json` rather than hitting the NetBird Management API, so callers don't need to handle API tokens — the daemon is already authenticated via `netbird up`.
Index ¶
Constants ¶
const ( // DaemonStatusConnected is the value of Status.DaemonStatus when the // local daemon is logged in and connected to the management server. DaemonStatusConnected = "Connected" // PeerStatusConnected is the value of Peer.Status when a peer has an // active mesh connection. We treat any other value as "not currently // reachable". PeerStatusConnected = "Connected" )
Variables ¶
This section is empty.
Functions ¶
func AccessibleClusters ¶
AccessibleClusters returns the cluster names from peers whose FQDN matches `<prefix><name><suffix>` and whose Status is Connected. The returned slice contains just the `<name>` portion — the prefix and suffix are stripped.
Example: prefix="k8s-", suffix=".netbird.selfhosted", a peer with fqdn "k8s-staging.netbird.selfhosted" produces "staging".
Peers that don't match the prefix/suffix or aren't Connected are filtered out. Returns an empty slice (never nil) so callers can iterate uniformly.
Types ¶
type ManagementInfo ¶
type ManagementInfo struct {
URL string `json:"url"`
Connected bool `json:"connected"`
Error string `json:"error,omitempty"`
}
ManagementInfo describes the daemon's view of the NetBird management server.
type PeersInfo ¶
type PeersInfo struct {
Total int `json:"total"`
Connected int `json:"connected"`
Details []Peer `json:"details"`
}
PeersInfo describes the peers known to the daemon.
type Status ¶
type Status struct {
DaemonStatus string `json:"daemonStatus"`
Management ManagementInfo `json:"management"`
Peers PeersInfo `json:"peers"`
}
Status is the shape of `netbird status --json` (the subset we use). The daemon emits many more fields; we deliberately ignore them so a future NetBird release adding fields doesn't break our parse.