Documentation
¶
Index ¶
- Constants
- Variables
- func CheckUIApp() bool
- func CtxGetState(ctx context.Context) *contextState
- func CtxInitState(ctx context.Context) context.Context
- func IsLoginRequired(ctx context.Context, config *profilemanager.Config) (bool, error)
- func Login(ctx context.Context, config *profilemanager.Config, setupKey string, ...) error
- type ConnMgr
- func (e *ConnMgr) ActivatePeer(ctx context.Context, conn *peer.Conn)
- func (e *ConnMgr) AddPeerConn(ctx context.Context, peerKey string, conn *peer.Conn) (exists bool)
- func (e *ConnMgr) Close()
- func (e *ConnMgr) DeactivatePeer(conn *peer.Conn)
- func (e *ConnMgr) RemovePeerConn(peerKey string)
- func (e *ConnMgr) SetExcludeList(ctx context.Context, peerIDs map[string]bool)
- func (e *ConnMgr) Start(ctx context.Context)
- func (e *ConnMgr) UpdateRouteHAMap(haMap route.HAMap)
- func (e *ConnMgr) UpdatedRemoteFeatureFlag(ctx context.Context, enabled bool) error
- type ConnectClient
- func (c *ConnectClient) Engine() *Engine
- func (c *ConnectClient) GetLatestSyncResponse() (*mgmProto.SyncResponse, error)
- func (c *ConnectClient) Run(runningChan chan struct{}) error
- func (c *ConnectClient) RunOnAndroid(tunAdapter device.TunAdapter, iFaceDiscover stdnet.ExternalIFaceDiscover, ...) error
- func (c *ConnectClient) RunOniOS(fileDescriptor int32, networkChangeListener listener.NetworkChangeListener, ...) error
- func (c *ConnectClient) SetSyncResponsePersistence(enabled bool)
- func (c *ConnectClient) Status() StatusType
- func (c *ConnectClient) Stop() error
- type DeviceAuthProviderConfig
- type DeviceAuthorizationFlow
- type Engine
- func (e *Engine) Address() (netip.Addr, error)
- func (e *Engine) GetFirewallManager() firewallManager.Manager
- func (e *Engine) GetLatestSyncResponse() (*mgmProto.SyncResponse, error)
- func (e *Engine) GetNet() (*netstack.Net, error)
- func (e *Engine) GetPeerSSHKey(peerAddress string) ([]byte, bool)
- func (e *Engine) GetRouteManager() routemanager.Manager
- func (e *Engine) GetSSHServerStatus() (enabled bool, sessions []sshserver.SessionInfo)
- func (e *Engine) GetWgAddr() netip.Addr
- func (e *Engine) PopulateNetbirdConfig(netbirdConfig *mgmProto.NetbirdConfig, mgmtURL *url.URL) error
- func (e *Engine) RenewTun(fd int) error
- func (e *Engine) RunHealthProbes(waitForResult bool) bool
- func (e *Engine) SetSyncResponsePersistence(enabled bool)
- func (e *Engine) Start(netbirdConfig *mgmProto.NetbirdConfig, mgmtURL *url.URL) error
- func (e *Engine) Stop() error
- type EngineConfig
- type MobileDependency
- type PKCEAuthProviderConfig
- type PKCEAuthorizationFlow
- type Peer
- type SessionWatcher
- type StatusType
- type WGIface
- type WGIfaceMonitor
Constants ¶
const ( PeerConnectionTimeoutMax = 45000 // ms PeerConnectionTimeoutMin = 30000 // ms )
PeerConnectionTimeoutMax is a timeout of an initial connection attempt to a remote peer. E.g. this peer will wait PeerConnectionTimeoutMax for the remote peer to respond, if not successful then it will retry the connection attempt. Todo pass timeout at EnginConfig
Variables ¶
var ErrResetConnection = fmt.Errorf("reset connection")
Functions ¶
func CtxGetState ¶
CtxGetState object to get/update state/errors of process.
func CtxInitState ¶
CtxInitState setup context state into the context tree.
This function should be used to initialize context before CtxGetState will be executed.
func IsLoginRequired ¶
IsLoginRequired check that the server is support SSO or not
Types ¶
type ConnMgr ¶
type ConnMgr struct {
// contains filtered or unexported fields
}
ConnMgr coordinates both lazy connections (established on-demand) and permanent peer connections.
The connection manager is responsible for: - Managing lazy connections via the lazyConnManager - Maintaining a list of excluded peers that should always have permanent connections - Handling connection establishment based on peer signaling
The implementation is not thread-safe; it is protected by engine.syncMsgMux.
func NewConnMgr ¶
func (*ConnMgr) AddPeerConn ¶
func (*ConnMgr) DeactivatePeer ¶
DeactivatePeer deactivates a peer connection in the lazy connection manager. If locally the lazy connection is disabled, we force the peer connection open.
func (*ConnMgr) RemovePeerConn ¶
func (*ConnMgr) SetExcludeList ¶
SetExcludeList sets the list of peer IDs that should always have permanent connections.
func (*ConnMgr) Start ¶
Start initializes the connection manager and starts the lazy connection manager if enabled by env var or cmd line option.
func (*ConnMgr) UpdateRouteHAMap ¶
UpdateRouteHAMap updates the route HA mappings in the lazy connection manager
func (*ConnMgr) UpdatedRemoteFeatureFlag ¶
UpdatedRemoteFeatureFlag is called when the remote feature flag is updated. If enabled, it initializes the lazy connection manager and start it. Do not need to call Start() again. If disabled, then it closes the lazy connection manager and open the connections to all peers.
type ConnectClient ¶
type ConnectClient struct {
// contains filtered or unexported fields
}
func NewConnectClient ¶
func NewConnectClient( ctx context.Context, config *profilemanager.Config, statusRecorder *peer.Status, ) *ConnectClient
func (*ConnectClient) Engine ¶
func (c *ConnectClient) Engine() *Engine
func (*ConnectClient) GetLatestSyncResponse ¶
func (c *ConnectClient) GetLatestSyncResponse() (*mgmProto.SyncResponse, error)
GetLatestSyncResponse returns the latest sync response from the engine.
func (*ConnectClient) Run ¶
func (c *ConnectClient) Run(runningChan chan struct{}) error
Run with main logic.
func (*ConnectClient) RunOnAndroid ¶
func (c *ConnectClient) RunOnAndroid( tunAdapter device.TunAdapter, iFaceDiscover stdnet.ExternalIFaceDiscover, networkChangeListener listener.NetworkChangeListener, dnsAddresses []netip.AddrPort, dnsReadyListener dns.ReadyListener, stateFilePath string, ) error
RunOnAndroid with main logic on mobile system
func (*ConnectClient) RunOniOS ¶
func (c *ConnectClient) RunOniOS( fileDescriptor int32, networkChangeListener listener.NetworkChangeListener, dnsManager dns.IosDnsManager, stateFilePath string, ) error
func (*ConnectClient) SetSyncResponsePersistence ¶
func (c *ConnectClient) SetSyncResponsePersistence(enabled bool)
SetSyncResponsePersistence enables or disables sync response persistence. When enabled, the last received sync response will be stored and can be retrieved through the Engine's GetLatestSyncResponse method. When disabled, any stored sync response will be cleared.
func (*ConnectClient) Status ¶
func (c *ConnectClient) Status() StatusType
Status returns the current client status
func (*ConnectClient) Stop ¶
func (c *ConnectClient) Stop() error
type DeviceAuthProviderConfig ¶
type DeviceAuthProviderConfig struct {
// ClientID An IDP application client id
ClientID string
// ClientSecret An IDP application client secret
ClientSecret string
// Domain An IDP API domain
// Deprecated. Use OIDCConfigEndpoint instead
Domain string
// Audience An Audience for to authorization validation
Audience string
// TokenEndpoint is the endpoint of an IDP manager where clients can obtain access token
TokenEndpoint string
// DeviceAuthEndpoint is the endpoint of an IDP manager where clients can obtain device authorization code
DeviceAuthEndpoint string
// Scopes provides the scopes to be included in the token request
Scope string
// UseIDToken indicates if the id token should be used for authentication
UseIDToken bool
// LoginHint is used to pre-fill the email/username field during authentication
LoginHint string
}
DeviceAuthProviderConfig has all attributes needed to initiate a device authorization flow
type DeviceAuthorizationFlow ¶
type DeviceAuthorizationFlow struct {
Provider string
ProviderConfig DeviceAuthProviderConfig
}
DeviceAuthorizationFlow represents Device Authorization Flow information
func GetDeviceAuthorizationFlowInfo ¶
func GetDeviceAuthorizationFlowInfo(ctx context.Context, privateKey string, mgmURL *url.URL) (DeviceAuthorizationFlow, error)
GetDeviceAuthorizationFlowInfo initialize a DeviceAuthorizationFlow instance and return with it
type Engine ¶
type Engine struct {
// STUNs is a list of STUN servers used by ICE
STUNs []*stun.URI
// TURNs is a list of STUN servers used by ICE
TURNs []*stun.URI
// contains filtered or unexported fields
}
Engine is a mechanism responsible for reacting on Signal and Management stream events and managing connections to the remote peers.
func NewEngine ¶
func NewEngine( clientCtx context.Context, clientCancel context.CancelFunc, signalClient signal.Client, mgmClient mgm.Client, relayManager *relayClient.Manager, config *EngineConfig, mobileDep MobileDependency, statusRecorder *peer.Status, checks []*mgmProto.Checks, ) *Engine
NewEngine creates a new Connection Engine with probes attached
func (*Engine) GetFirewallManager ¶
func (e *Engine) GetFirewallManager() firewallManager.Manager
GetFirewallManager returns the firewall manager
func (*Engine) GetLatestSyncResponse ¶
func (e *Engine) GetLatestSyncResponse() (*mgmProto.SyncResponse, error)
GetLatestSyncResponse returns the stored sync response if persistence is enabled
func (*Engine) GetPeerSSHKey ¶
GetPeerSSHKey returns the SSH host key for a specific peer by IP or FQDN
func (*Engine) GetRouteManager ¶
func (e *Engine) GetRouteManager() routemanager.Manager
GetRouteManager returns the route manager
func (*Engine) GetSSHServerStatus ¶
func (e *Engine) GetSSHServerStatus() (enabled bool, sessions []sshserver.SessionInfo)
GetSSHServerStatus returns the SSH server status and active sessions
func (*Engine) PopulateNetbirdConfig ¶
func (e *Engine) PopulateNetbirdConfig(netbirdConfig *mgmProto.NetbirdConfig, mgmtURL *url.URL) error
PopulateNetbirdConfig populates the DNS cache with infrastructure domains from login response
func (*Engine) RunHealthProbes ¶
RunHealthProbes executes health checks for Signal, Management, Relay and WireGuard services and updates the status recorder with the latest states.
func (*Engine) SetSyncResponsePersistence ¶
SetSyncResponsePersistence enables or disables sync response persistence
func (*Engine) Start ¶
Start creates a new WireGuard tunnel interface and listens to events from Signal and Management services Connections to remote peers are not established here. However, they will be established once an event with a list of peers to connect to will be received from Management Service
type EngineConfig ¶
type EngineConfig struct {
WgPort int
WgIfaceName string
// WgAddr is a Wireguard local address (Netbird Network IP)
WgAddr string
// WgPrivateKey is a Wireguard private key of our peer (it MUST never leave the machine)
WgPrivateKey wgtypes.Key
// NetworkMonitor is a flag to enable network monitoring
NetworkMonitor bool
// IFaceBlackList is a list of network interfaces to ignore when discovering connection candidates (ICE related)
IFaceBlackList []string
DisableIPv6Discovery bool
// UDPMuxPort default value 0 - the system will pick an available port
UDPMuxPort int
// UDPMuxSrflxPort default value 0 - the system will pick an available port
UDPMuxSrflxPort int
// SSHKey is a private SSH key in a PEM format
SSHKey []byte
NATExternalIPs []string
CustomDNSAddress string
RosenpassEnabled bool
RosenpassPermissive bool
ServerSSHAllowed bool
EnableSSHRoot *bool
EnableSSHSFTP *bool
EnableSSHLocalPortForwarding *bool
EnableSSHRemotePortForwarding *bool
DisableSSHAuth *bool
DNSRouteInterval time.Duration
DisableClientRoutes bool
DisableServerRoutes bool
DisableDNS bool
DisableFirewall bool
BlockLANAccess bool
BlockInbound bool
LazyConnectionEnabled bool
MTU uint16
}
EngineConfig is a config for the Engine
type MobileDependency ¶
type MobileDependency struct {
// Android only
TunAdapter device.TunAdapter
IFaceDiscover stdnet.ExternalIFaceDiscover
NetworkChangeListener listener.NetworkChangeListener
HostDNSAddresses []netip.AddrPort
DnsReadyListener dns.ReadyListener
// iOS only
DnsManager dns.IosDnsManager
FileDescriptor int32
StateFilePath string
}
MobileDependency collect all dependencies for mobile platform
type PKCEAuthProviderConfig ¶
type PKCEAuthProviderConfig struct {
// ClientID An IDP application client id
ClientID string
// ClientSecret An IDP application client secret
ClientSecret string
// Audience An Audience for to authorization validation
Audience string
// TokenEndpoint is the endpoint of an IDP manager where clients can obtain access token
TokenEndpoint string
// AuthorizationEndpoint is the endpoint of an IDP manager where clients can obtain authorization code
AuthorizationEndpoint string
// Scopes provides the scopes to be included in the token request
Scope string
// RedirectURL handles authorization code from IDP manager
RedirectURLs []string
// UseIDToken indicates if the id token should be used for authentication
UseIDToken bool
// ClientCertPair is used for mTLS authentication to the IDP
ClientCertPair *tls.Certificate
// DisablePromptLogin makes the PKCE flow to not prompt the user for login
DisablePromptLogin bool
// LoginFlag is used to configure the PKCE flow login behavior
LoginFlag common.LoginFlag
// LoginHint is used to pre-fill the email/username field during authentication
LoginHint string
}
PKCEAuthProviderConfig has all attributes needed to initiate pkce authorization flow
type PKCEAuthorizationFlow ¶
type PKCEAuthorizationFlow struct {
ProviderConfig PKCEAuthProviderConfig
}
PKCEAuthorizationFlow represents PKCE Authorization Flow information
func GetPKCEAuthorizationFlowInfo ¶
func GetPKCEAuthorizationFlowInfo(ctx context.Context, privateKey string, mgmURL *url.URL, clientCert *tls.Certificate) (PKCEAuthorizationFlow, error)
GetPKCEAuthorizationFlowInfo initialize a PKCEAuthorizationFlow instance and return with it
type SessionWatcher ¶
type SessionWatcher struct {
// contains filtered or unexported fields
}
func NewSessionWatcher ¶
func NewSessionWatcher(ctx context.Context, peerStatusRecorder *peer.Status) *SessionWatcher
NewSessionWatcher creates a new instance of SessionWatcher.
func (*SessionWatcher) SetOnExpireListener ¶
func (s *SessionWatcher) SetOnExpireListener(onExpire func())
SetOnExpireListener sets the callback func to be called when the session expires.
type StatusType ¶
type StatusType string
const ( StatusIdle StatusType = "Idle" StatusConnecting StatusType = "Connecting" StatusConnected StatusType = "Connected" StatusNeedsLogin StatusType = "NeedsLogin" StatusLoginFailed StatusType = "LoginFailed" StatusSessionExpired StatusType = "SessionExpired" )
type WGIfaceMonitor ¶
type WGIfaceMonitor struct {
// contains filtered or unexported fields
}
WGIfaceMonitor monitors the WireGuard interface lifecycle and restarts the engine if the interface is deleted externally while the engine is running.
func NewWGIfaceMonitor ¶
func NewWGIfaceMonitor() *WGIfaceMonitor
NewWGIfaceMonitor creates a new WGIfaceMonitor instance.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
mocks
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |
|
Package lazyconn provides mechanisms for managing lazy connections, which activate on demand to optimize resource usage and establish connections efficiently.
|
Package lazyconn provides mechanisms for managing lazy connections, which activate on demand to optimize resource usage and establish connections efficiently. |
|
Package stdnet is an extension of the pion's stdnet.
|
Package stdnet is an extension of the pion's stdnet. |