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) GetRouteManager() routemanager.Manager
- func (e *Engine) GetWgAddr() netip.Addr
- func (e *Engine) RunHealthProbes() bool
- func (e *Engine) SetSyncResponsePersistence(enabled bool)
- func (e *Engine) Start() error
- func (e *Engine) Stop() error
- type EngineConfig
- type MobileDependency
- type PKCEAuthProviderConfig
- type PKCEAuthorizationFlow
- type Peer
- type SessionWatcher
- type StatusType
- type WGIface
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 CheckUIApp ¶ added in v0.26.3
func CheckUIApp() bool
CheckUIApp checks whether UI application is running.
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 ¶ added in v0.14.5
IsLoginRequired check that the server is support SSO or not
Types ¶
type ConnMgr ¶ added in v0.45.0
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 ¶ added in v0.45.0
func (*ConnMgr) ActivatePeer ¶ added in v0.50.0
func (*ConnMgr) AddPeerConn ¶ added in v0.45.0
func (*ConnMgr) DeactivatePeer ¶ added in v0.50.0
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 ¶ added in v0.45.0
func (*ConnMgr) SetExcludeList ¶ added in v0.45.0
SetExcludeList sets the list of peer IDs that should always have permanent connections.
func (*ConnMgr) Start ¶ added in v0.45.0
Start initializes the connection manager and starts the lazy connection manager if enabled by env var or cmd line option.
func (*ConnMgr) UpdateRouteHAMap ¶ added in v0.47.0
UpdateRouteHAMap updates the route HA mappings in the lazy connection manager
func (*ConnMgr) UpdatedRemoteFeatureFlag ¶ added in v0.45.0
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 ¶ added in v0.27.5
type ConnectClient struct {
// contains filtered or unexported fields
}
func NewConnectClient ¶ added in v0.27.5
func NewConnectClient( ctx context.Context, config *profilemanager.Config, statusRecorder *peer.Status, ) *ConnectClient
func (*ConnectClient) Engine ¶ added in v0.27.5
func (c *ConnectClient) Engine() *Engine
func (*ConnectClient) GetLatestSyncResponse ¶ added in v0.53.0
func (c *ConnectClient) GetLatestSyncResponse() (*mgmProto.SyncResponse, error)
GetLatestSyncResponse returns the latest sync response from the engine.
func (*ConnectClient) Run ¶ added in v0.27.5
func (c *ConnectClient) Run(runningChan chan struct{}) error
Run with main logic.
func (*ConnectClient) RunOnAndroid ¶ added in v0.27.5
func (c *ConnectClient) RunOnAndroid( tunAdapter device.TunAdapter, iFaceDiscover stdnet.ExternalIFaceDiscover, networkChangeListener listener.NetworkChangeListener, dnsAddresses []netip.AddrPort, dnsReadyListener dns.ReadyListener, ) error
RunOnAndroid with main logic on mobile system
func (*ConnectClient) RunOniOS ¶ added in v0.27.5
func (c *ConnectClient) RunOniOS( fileDescriptor int32, networkChangeListener listener.NetworkChangeListener, dnsManager dns.IosDnsManager, stateFilePath string, ) error
func (*ConnectClient) SetSyncResponsePersistence ¶ added in v0.53.0
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 ¶ added in v0.34.0
func (c *ConnectClient) Status() StatusType
Status returns the current client status
func (*ConnectClient) Stop ¶ added in v0.29.0
func (c *ConnectClient) Stop() error
type DeviceAuthProviderConfig ¶ added in v0.22.0
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 }
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 ¶ added in v0.36.6
func (e *Engine) GetFirewallManager() firewallManager.Manager
GetFirewallManager returns the firewall manager
func (*Engine) GetLatestSyncResponse ¶ added in v0.53.0
func (e *Engine) GetLatestSyncResponse() (*mgmProto.SyncResponse, error)
GetLatestSyncResponse returns the stored sync response if persistence is enabled
func (*Engine) GetRouteManager ¶ added in v0.27.4
func (e *Engine) GetRouteManager() routemanager.Manager
GetRouteManager returns the route manager
func (*Engine) RunHealthProbes ¶ added in v0.36.5
RunHealthProbes executes health checks for Signal, Management, Relay and WireGuard services and updates the status recorder with the latest states.
func (*Engine) SetSyncResponsePersistence ¶ added in v0.53.0
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 DNSRouteInterval time.Duration DisableClientRoutes bool DisableServerRoutes bool DisableDNS bool DisableFirewall bool BlockLANAccess bool BlockInbound bool LazyConnectionEnabled bool }
EngineConfig is a config for the Engine
type MobileDependency ¶ added in v0.17.0
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 ¶ added in v0.22.0
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 }
PKCEAuthProviderConfig has all attributes needed to initiate pkce authorization flow
type PKCEAuthorizationFlow ¶ added in v0.22.0
type PKCEAuthorizationFlow struct {
ProviderConfig PKCEAuthProviderConfig
}
PKCEAuthorizationFlow represents PKCE Authorization Flow information
func GetPKCEAuthorizationFlowInfo ¶ added in v0.22.0
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 ¶ added in v0.26.3
type SessionWatcher struct {
// contains filtered or unexported fields
}
func NewSessionWatcher ¶ added in v0.26.3
func NewSessionWatcher(ctx context.Context, peerStatusRecorder *peer.Status) *SessionWatcher
NewSessionWatcher creates a new instance of SessionWatcher.
func (*SessionWatcher) SetOnExpireListener ¶ added in v0.26.3
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" )
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. |