Documentation
¶
Overview ¶
Package embed provides a way to embed the NetBird client directly into Go programs without requiring a separate NetBird client installation.
Index ¶
- Variables
- type Client
- func (c *Client) Dial(ctx context.Context, network, address string) (net.Conn, error)
- func (c *Client) DialContext(ctx context.Context, network, address string) (net.Conn, error)
- func (c *Client) GetConfig() (profilemanager.Config, error)
- func (c *Client) ListenTCP(address string) (net.Listener, error)
- func (c *Client) ListenUDP(address string) (net.PacketConn, error)
- func (c *Client) NewHTTPClient() *http.Client
- func (c *Client) Start(startCtx context.Context) error
- func (c *Client) Stop(ctx context.Context) error
- func (c *Client) VerifySSHHostKey(peerAddress string, key []byte) error
- type Options
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client manages a netbird embedded client instance.
func (*Client) Dial ¶
Dial dials a network address in the netbird network. Not applicable if the userspace networking mode is disabled.
func (*Client) DialContext ¶ added in v0.60.0
DialContext dials a network address in the netbird network with context
func (*Client) GetConfig ¶ added in v0.59.0
func (c *Client) GetConfig() (profilemanager.Config, error)
GetConfig returns a copy of the internal client config.
func (*Client) ListenTCP ¶
ListenTCP listens on the given address in the netbird network. Not applicable if the userspace networking mode is disabled.
func (*Client) ListenUDP ¶
func (c *Client) ListenUDP(address string) (net.PacketConn, error)
ListenUDP listens on the given address in the netbird network. Not applicable if the userspace networking mode is disabled.
func (*Client) NewHTTPClient ¶
NewHTTPClient returns a configured http.Client that uses the netbird network for requests. Not applicable if the userspace networking mode is disabled.
func (*Client) Start ¶
Start begins client operation and blocks until the engine has been started successfully or a startup error occurs. Pass a context with a deadline to limit the time spent waiting for the engine to start.
func (*Client) Stop ¶
Stop gracefully stops the client. Pass a context with a deadline to limit the time spent waiting for the engine to stop.
func (*Client) VerifySSHHostKey ¶ added in v0.60.0
VerifySSHHostKey verifies an SSH host key against stored peer keys. Returns nil if the key matches, ErrPeerNotFound if peer is not in network, ErrNoStoredKey if peer has no stored key, or an error for verification failures.
type Options ¶
type Options struct {
// DeviceName is this peer's name in the network
DeviceName string
// SetupKey is used for authentication
SetupKey string
// JWTToken is used for JWT-based authentication
JWTToken string
// PrivateKey is used for direct private key authentication
PrivateKey string
// ManagementURL overrides the default management server URL
ManagementURL string
PreSharedKey string
// LogOutput is the output destination for logs (defaults to os.Stderr if nil)
LogOutput io.Writer
// LogLevel sets the logging level (defaults to info if empty)
LogLevel string
// NoUserspace disables the userspace networking mode. Needs admin/root privileges
NoUserspace bool
// ConfigPath is the path to the netbird config file. If empty, the config will be stored in memory and not persisted.
ConfigPath string
// StatePath is the path to the netbird state file
StatePath string
// DisableClientRoutes disables the client routes
DisableClientRoutes bool
}
Options configures a new Client.