netbird

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: May 18, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

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

View Source
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

func AccessibleClusters(s *Status, prefix, suffix string) []string

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 Peer

type Peer struct {
	FQDN   string `json:"fqdn"`
	Status string `json:"status"`
}

Peer is one mesh peer entry.

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.

func FetchStatus

func FetchStatus(ctx context.Context) (*Status, error)

FetchStatus runs `netbird status --json` and parses the output.

Jump to

Keyboard shortcuts

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