Documentation ¶
Index ¶
- Constants
- Variables
- func CtxGetState(ctx context.Context) *contextState
- func CtxInitState(ctx context.Context) context.Context
- func IsLoginRequired(ctx context.Context, privateKey string, mgmURL *url.URL, sshKey string) (bool, error)
- func Login(ctx context.Context, config *Config, setupKey string, jwtToken string) error
- func RunClient(ctx context.Context, config *Config, statusRecorder *peer.Status) error
- func RunClientMobile(ctx context.Context, config *Config, statusRecorder *peer.Status, ...) error
- func RunClientiOS(ctx context.Context, config *Config, statusRecorder *peer.Status, ...) error
- func SignalOfferAnswer(offerAnswer peer.OfferAnswer, myKey wgtypes.Key, remoteKey wgtypes.Key, ...) error
- func WriteOutConfig(path string, config *Config) error
- type Config
- func CreateInMemoryConfig(input ConfigInput) (*Config, error)
- func ReadConfig(configPath string) (*Config, error)
- func UpdateConfig(input ConfigInput) (*Config, error)
- func UpdateOldManagementURL(ctx context.Context, config *Config, configPath string) (*Config, error)
- func UpdateOrCreateConfig(input ConfigInput) (*Config, error)
- type ConfigInput
- type DeviceAuthProviderConfig
- type DeviceAuthorizationFlow
- type Engine
- type EngineConfig
- type MobileDependency
- type PKCEAuthProviderConfig
- type PKCEAuthorizationFlow
- type Peer
- type StatusType
Constants ¶
const ( // DefaultManagementURL points to the NetBird's cloud management endpoint DefaultManagementURL = "https://api.netbird.io:443" // DefaultAdminURL points to NetBird's cloud management console DefaultAdminURL = "https://app.netbird.io:443" )
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 ¶
func IsLoginRequired(ctx context.Context, privateKey string, mgmURL *url.URL, sshKey string) (bool, error)
IsLoginRequired check that the server is support SSO or not
func RunClientMobile ¶
func RunClientMobile(ctx context.Context, config *Config, statusRecorder *peer.Status, tunAdapter iface.TunAdapter, iFaceDiscover stdnet.ExternalIFaceDiscover, networkChangeListener listener.NetworkChangeListener, dnsAddresses []string, dnsReadyListener dns.ReadyListener) error
RunClientMobile with main logic on mobile system
func RunClientiOS ¶
func SignalOfferAnswer ¶
func SignalOfferAnswer(offerAnswer peer.OfferAnswer, myKey wgtypes.Key, remoteKey wgtypes.Key, s signal.Client, isAnswer bool) error
SignalOfferAnswer signals either an offer or an answer to remote peer
func WriteOutConfig ¶
WriteOutConfig write put the prepared config to the given path
Types ¶
type Config ¶
type Config struct { // Wireguard private key of local peer PrivateKey string ManagementURL *url.URL AdminURL *url.URL WgIface string WgPort int IFaceBlackList []string DisableIPv6Discovery bool // SSHKey is a private SSH key in a PEM format SSHKey string NATExternalIPs []string // CustomDNSAddress sets the DNS resolver listening address in format ip:port CustomDNSAddress string }
Config Configuration type
func CreateInMemoryConfig ¶
func CreateInMemoryConfig(input ConfigInput) (*Config, error)
CreateInMemoryConfig generate a new config but do not write out it to the store
func ReadConfig ¶
ReadConfig read config file and return with Config. If it is not exists create a new with default values
func UpdateConfig ¶
func UpdateConfig(input ConfigInput) (*Config, error)
UpdateConfig update existing configuration according to input configuration and return with the configuration
func UpdateOldManagementURL ¶
func UpdateOldManagementURL(ctx context.Context, config *Config, configPath string) (*Config, error)
UpdateOldManagementURL checks whether client can switch to the new Management URL with port 443 and the management domain. If it can switch, then it updates the config and returns a new one. Otherwise, it returns the provided config. The check is performed only for the NetBird's managed version.
func UpdateOrCreateConfig ¶
func UpdateOrCreateConfig(input ConfigInput) (*Config, error)
UpdateOrCreateConfig reads existing config or generates a new one
type ConfigInput ¶
type ConfigInput struct { ManagementURL string AdminURL string ConfigPath string NATExternalIPs []string CustomDNSAddress []byte }
ConfigInput carries configuration changes to the client
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 }
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( ctx context.Context, cancel context.CancelFunc, signalClient signal.Client, mgmClient mgm.Client, config *EngineConfig, mobileDep MobileDependency, statusRecorder *peer.Status, ) *Engine
NewEngine creates a new Connection Engine
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 // 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 }
EngineConfig is a config for the Engine
type MobileDependency ¶
type MobileDependency struct { // Android only TunAdapter iface.TunAdapter IFaceDiscover stdnet.ExternalIFaceDiscover NetworkChangeListener listener.NetworkChangeListener HostDNSAddresses []string DnsReadyListener dns.ReadyListener // iOS only DnsManager dns.IosDnsManager FileDescriptor int32 }
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 }
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) (PKCEAuthorizationFlow, error)
GetPKCEAuthorizationFlowInfo initialize a PKCEAuthorizationFlow instance and return with it
type StatusType ¶
type StatusType string
const ( StatusIdle StatusType = "Idle" StatusConnecting StatusType = "Connecting" StatusConnected StatusType = "Connected" StatusNeedsLogin StatusType = "NeedsLogin" StatusLoginFailed StatusType = "LoginFailed" )