Documentation
¶
Index ¶
- Constants
- Variables
- func WriteOutConfig(path string, config *Config) error
- type ActiveProfileState
- type Config
- func CreateInMemoryConfig(input ConfigInput) (*Config, error)
- func GetConfig(configPath string) (*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 Profile
- type ProfileManager
- type ProfileState
- type ServiceManager
- func (s *ServiceManager) AddProfile(profileName, username string) error
- func (s *ServiceManager) CopyDefaultProfileIfNotExists() (bool, error)
- func (s *ServiceManager) CreateDefaultProfile() error
- func (s *ServiceManager) DefaultProfilePath() string
- func (s *ServiceManager) GetActiveProfileState() (*ActiveProfileState, error)
- func (s *ServiceManager) GetStatePath() string
- func (s *ServiceManager) ListProfiles(username string) ([]Profile, error)
- func (s *ServiceManager) RemoveProfile(profileName, username string) error
- func (s *ServiceManager) SetActiveProfileState(a *ActiveProfileState) error
- func (s *ServiceManager) SetActiveProfileStateToDefault() error
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" )
Variables ¶
var ( ErrProfileNotFound = errors.New("profile not found") ErrProfileAlreadyExists = errors.New("profile already exists") ErrNoActiveProfile = errors.New("no active profile set") )
var ( DefaultConfigPathDir = "" DefaultConfigPath = "" ActiveProfileStatePath = "" )
var ConfigDirOverride string
var DefaultInterfaceBlacklist = []string{ iface.WgInterfaceDefault, "wt", "utun", "tun0", "zt", "ZeroTier", "wg", "ts", "Tailscale", "tailscale", "docker", "veth", "br-", "lo", }
var (
ErrorOldDefaultConfigNotFound = errors.New("old default config not found")
)
Functions ¶
func WriteOutConfig ¶
WriteOutConfig write put the prepared config to the given path
Types ¶
type ActiveProfileState ¶
func (*ActiveProfileState) FilePath ¶
func (a *ActiveProfileState) FilePath() (string, error)
type Config ¶
type Config struct {
// Wireguard private key of local peer
PrivateKey string
ManagementURL *url.URL
AdminURL *url.URL
WgIface string
WgPort int
NetworkMonitor *bool
IFaceBlackList []string
DisableIPv6Discovery bool
RosenpassEnabled bool
RosenpassPermissive bool
ServerSSHAllowed *bool
DisableClientRoutes bool
DisableServerRoutes bool
DisableDNS bool
DisableFirewall bool
BlockLANAccess bool
BlockInbound bool
DisableNotifications *bool
DNSLabels domain.List
// 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
// DisableAutoConnect determines whether the client should not start with the service
// it's set to false by default due to backwards compatibility
DisableAutoConnect bool
// DNSRouteInterval is the interval in which the DNS routes are updated
DNSRouteInterval time.Duration
// Path to a certificate used for mTLS authentication
ClientCertPath string
// Path to corresponding private key of ClientCertPath
ClientCertKeyPath string
ClientCertKeyPair *tls.Certificate `json:"-"`
LazyConnectionEnabled bool
}
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
StateFilePath string
ServerSSHAllowed *bool
NATExternalIPs []string
CustomDNSAddress []byte
RosenpassEnabled *bool
RosenpassPermissive *bool
InterfaceName *string
WireguardPort *int
NetworkMonitor *bool
DisableAutoConnect *bool
ExtraIFaceBlackList []string
DNSRouteInterval *time.Duration
ClientCertPath string
ClientCertKeyPath string
DisableClientRoutes *bool
DisableServerRoutes *bool
DisableDNS *bool
DisableFirewall *bool
BlockLANAccess *bool
BlockInbound *bool
DisableNotifications *bool
DNSLabels domain.List
LazyConnectionEnabled *bool
}
ConfigInput carries configuration changes to the client
type ProfileManager ¶
type ProfileManager struct {
// contains filtered or unexported fields
}
func NewProfileManager ¶
func NewProfileManager() *ProfileManager
func (*ProfileManager) GetActiveProfile ¶
func (pm *ProfileManager) GetActiveProfile() (*Profile, error)
func (*ProfileManager) GetProfileState ¶
func (pm *ProfileManager) GetProfileState(profileName string) (*ProfileState, error)
func (*ProfileManager) SetActiveProfileState ¶
func (pm *ProfileManager) SetActiveProfileState(state *ProfileState) error
func (*ProfileManager) SwitchProfile ¶
func (pm *ProfileManager) SwitchProfile(profileName string) error
type ProfileState ¶
type ProfileState struct {
Email string `json:"email"`
}
type ServiceManager ¶
type ServiceManager struct{}
func (*ServiceManager) AddProfile ¶
func (s *ServiceManager) AddProfile(profileName, username string) error
func (*ServiceManager) CopyDefaultProfileIfNotExists ¶
func (s *ServiceManager) CopyDefaultProfileIfNotExists() (bool, error)
func (*ServiceManager) CreateDefaultProfile ¶
func (s *ServiceManager) CreateDefaultProfile() error
func (*ServiceManager) DefaultProfilePath ¶
func (s *ServiceManager) DefaultProfilePath() string
func (*ServiceManager) GetActiveProfileState ¶
func (s *ServiceManager) GetActiveProfileState() (*ActiveProfileState, error)
func (*ServiceManager) GetStatePath ¶
func (s *ServiceManager) GetStatePath() string
GetStatePath returns the path to the state file based on the operating system It returns an empty string if the path cannot be determined.
func (*ServiceManager) ListProfiles ¶
func (s *ServiceManager) ListProfiles(username string) ([]Profile, error)
func (*ServiceManager) RemoveProfile ¶
func (s *ServiceManager) RemoveProfile(profileName, username string) error
func (*ServiceManager) SetActiveProfileState ¶
func (s *ServiceManager) SetActiveProfileState(a *ActiveProfileState) error
func (*ServiceManager) SetActiveProfileStateToDefault ¶
func (s *ServiceManager) SetActiveProfileStateToDefault() error