Documentation
¶
Overview ¶
Package embed provides a way to embed the NetBird client directly into Go programs without requiring a separate NetBird client installation.
Index ¶
- Constants
- 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) Expose(ctx context.Context, req ExposeRequest) (*ExposeSession, error)
- func (c *Client) GetConfig() (profilemanager.Config, error)
- func (c *Client) GetLatestSyncResponse() (*mgmProto.SyncResponse, 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) SetLogLevel(levelStr string) error
- func (c *Client) Start(startCtx context.Context) error
- func (c *Client) Status() (peer.FullStatus, error)
- func (c *Client) Stop(ctx context.Context) error
- func (c *Client) VerifySSHHostKey(peerAddress string, key []byte) error
- type ExposeProtocolType
- type ExposeRequest
- type ExposeSession
- type Options
- type PeerConnStatus
Constants ¶
const ( // ExposeProtocolHTTP exposes the service as HTTP. ExposeProtocolHTTP = expose.ProtocolHTTP // ExposeProtocolHTTPS exposes the service as HTTPS. ExposeProtocolHTTPS = expose.ProtocolHTTPS // ExposeProtocolTCP exposes the service as TCP. ExposeProtocolTCP = expose.ProtocolTCP // ExposeProtocolUDP exposes the service as UDP. ExposeProtocolUDP = expose.ProtocolUDP // ExposeProtocolTLS exposes the service as TLS. ExposeProtocolTLS = expose.ProtocolTLS )
const ( // PeerStatusConnected indicates the peer is in connected state. PeerStatusConnected = peer.StatusConnected )
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) Expose ¶ added in v0.67.2
func (c *Client) Expose(ctx context.Context, req ExposeRequest) (*ExposeSession, error)
Expose exposes a local service via the NetBird reverse proxy, making it accessible through a public URL. It returns an ExposeSession. Call Wait on the session to keep it alive.
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) GetLatestSyncResponse ¶ added in v0.63.0
func (c *Client) GetLatestSyncResponse() (*mgmProto.SyncResponse, error)
GetLatestSyncResponse returns the latest sync response from the management server.
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) SetLogLevel ¶ added in v0.63.0
SetLogLevel sets the logging level for the client and its components.
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) Status ¶ added in v0.63.0
func (c *Client) Status() (peer.FullStatus, error)
Status returns the current status of the client.
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 ExposeProtocolType ¶ added in v0.67.2
type ExposeProtocolType = expose.ProtocolType
ExposeProtocolType represents the protocol used for exposing a service.
type ExposeRequest ¶ added in v0.67.2
ExposeRequest is a request to expose a local service via the NetBird reverse proxy.
type ExposeSession ¶ added in v0.67.2
type ExposeSession struct {
Domain string
ServiceName string
ServiceURL string
// contains filtered or unexported fields
}
ExposeSession represents an active expose session. Use Wait to block until the session ends.
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
// BlockInbound blocks all inbound connections from peers
BlockInbound bool
// WireguardPort is the port for the WireGuard interface. Use 0 for a random port.
WireguardPort *int
// MTU is the MTU for the WireGuard interface.
// Valid values are in the range 576..8192 bytes.
// If non-nil, this value overrides any value stored in the config file.
// If nil, the existing config MTU (if non-zero) is preserved; otherwise it defaults to 1280.
// Set to a higher value (e.g. 1400) if carrying QUIC or other protocols that require larger datagrams.
MTU *uint16
// DNSLabels defines additional DNS labels configured in the peer.
DNSLabels []string
}
Options configures a new Client.
type PeerConnStatus ¶ added in v0.65.0
type PeerConnStatus = peer.ConnStatus
PeerConnStatus is a peer's connection status.