Documentation ¶
Overview ¶
Package config provides functions for managing configuration of the daemon application.
Index ¶
- Variables
- func IsUnderSnap() bool
- type Allowlist
- func (a *Allowlist) GetSubnets() []string
- func (a *Allowlist) GetTCPPorts() []int64
- func (a *Allowlist) GetUDPPorts() []int64
- func (a *Allowlist) UpdateSubnets(subnet string, remove bool)
- func (a *Allowlist) UpdateTCPPorts(ports []int64, remove bool)
- func (a *Allowlist) UpdateUDPPorts(ports []int64, remove bool)
- type AutoConnectData
- type Config
- type ConfigPublisher
- type DNS
- type Field
- type FileReader
- type FilesystemConfigManager
- type FilesystemHandle
- type HostNameReader
- type MachineID
- type MachineIDGetter
- type Manager
- type NCData
- type PortSet
- type Ports
- type Protocol
- type SaveFunc
- type ServerGroup
- func (ServerGroup) Descriptor() protoreflect.EnumDescriptor
- func (x ServerGroup) Enum() *ServerGroup
- func (ServerGroup) EnumDescriptor() ([]byte, []int)deprecated
- func (x ServerGroup) Number() protoreflect.EnumNumber
- func (x ServerGroup) String() string
- func (ServerGroup) Type() protoreflect.EnumType
- type StdFilesystemHandle
- type Subnets
- type Technology
- type TokenData
- type TrueField
- type UidBoolMap
- type UsersData
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ( ServerGroup_name = map[int32]string{ 0: "UNDEFINED", 1: "DoubleVPN", 3: "ONION_OVER_VPN", 5: "ULTRA_FAST_TV", 7: "ANTI_DDOS", 9: "DEDICATED_IP", 11: "STANDARD_VPN_SERVERS", 13: "NETFLIX_USA", 15: "P2P", 17: "OBFUSCATED", 19: "EUROPE", 21: "THE_AMERICAS", 23: "ASIA_PACIFIC", 25: "AFRICA_MIDDLE_EAST_INDIA", } ServerGroup_value = map[string]int32{ "UNDEFINED": 0, "DoubleVPN": 1, "ONION_OVER_VPN": 3, "ULTRA_FAST_TV": 5, "ANTI_DDOS": 7, "DEDICATED_IP": 9, "STANDARD_VPN_SERVERS": 11, "NETFLIX_USA": 13, "P2P": 15, "OBFUSCATED": 17, "EUROPE": 19, "THE_AMERICAS": 21, "ASIA_PACIFIC": 23, "AFRICA_MIDDLE_EAST_INDIA": 25, } )
Enum value maps for ServerGroup.
var ( // InstallFilePath defines filename of install id file InstallFilePath = filepath.Join(internal.DatFilesPathCommon, "install.dat") // SettingsDataFilePath defines path to app configs file SettingsDataFilePath = filepath.Join(internal.DatFilesPath, "settings.dat") )
var ( Protocol_name = map[int32]string{ 0: "UNKNOWN_PROTOCOL", 1: "UDP", 2: "TCP", 3: "Webtunnel", } Protocol_value = map[string]int32{ "UNKNOWN_PROTOCOL": 0, "UDP": 1, "TCP": 2, "Webtunnel": 3, } )
Enum value maps for Protocol.
var ( Technology_name = map[int32]string{ 0: "UNKNOWN_TECHNOLOGY", 1: "OPENVPN", 2: "NORDLYNX", 3: "NORDWHISPER", } Technology_value = map[string]int32{ "UNKNOWN_TECHNOLOGY": 0, "OPENVPN": 1, "NORDLYNX": 2, "NORDWHISPER": 3, } )
Enum value maps for Technology.
var File_protobuf_daemon_config_group_proto protoreflect.FileDescriptor
var File_protobuf_daemon_config_protocol_proto protoreflect.FileDescriptor
var File_protobuf_daemon_config_technology_proto protoreflect.FileDescriptor
var GroupMap = map[string]ServerGroup{ "double_vpn": ServerGroup_DoubleVPN, "onion_over_vpn": ServerGroup_ONION_OVER_VPN, "dedicated_ip": ServerGroup_DEDICATED_IP, "standard_vpn_servers": ServerGroup_STANDARD_VPN_SERVERS, "p2p": ServerGroup_P2P, "europe": ServerGroup_EUROPE, "the_americas": ServerGroup_THE_AMERICAS, "asia_pacific": ServerGroup_ASIA_PACIFIC, "africa_the_middle_east_and_india": ServerGroup_AFRICA_MIDDLE_EAST_INDIA, "obfuscated_servers": ServerGroup_OBFUSCATED, }
GroupMap maps group titles to IDs
Functions ¶
Types ¶
type Allowlist ¶
Allowlist is a collection of ports and subnets
func NewAllowlist ¶
NewAllowlist ready to use
func (*Allowlist) GetSubnets ¶
GetSubnets returns a slice of all subnets within the allowlist
func (*Allowlist) GetTCPPorts ¶
GetTCPPorts returns a slice of all TCP ports within the allowlist
func (*Allowlist) GetUDPPorts ¶
GetUDPPorts returns a slice of all UDP ports within the allowlist
func (*Allowlist) UpdateSubnets ¶
func (*Allowlist) UpdateTCPPorts ¶
func (*Allowlist) UpdateUDPPorts ¶
type AutoConnectData ¶
type AutoConnectData struct { ID int64 `json:"id,omitempty"` ServerTag string `json:"server_tag,omitempty"` Country string City string Group ServerGroup Protocol Protocol `json:"protocol,omitempty"` // TODO: rename json key when v4 comes out. ThreatProtectionLite bool `json:"cybersec,omitempty"` Obfuscate bool `json:"obfuscate,omitempty"` DNS DNS `json:"dns,omitempty"` Allowlist Allowlist `json:"whitelist,omitempty"` PostquantumVpn bool `json:"postquantum_vpn"` }
type Config ¶
type Config struct { Technology Technology `json:"technology,omitempty"` Firewall bool `json:"firewall"` // omitempty breaks this FirewallMark uint32 `json:"fwmark"` Routing TrueField `json:"routing"` Analytics TrueField `json:"analytics"` Mesh bool `json:"mesh"` // MeshPrivateKey is base64 encoded MeshPrivateKey string `json:"mesh_private_key"` MeshDevice *mesh.Machine `json:"mesh_device"` KillSwitch bool `json:"kill_switch,omitempty"` AutoConnect bool `json:"auto_connect,omitempty"` IPv6 bool `json:"ipv6"` Meshnet meshnet `json:"meshnet"` AutoConnectData AutoConnectData `json:"auto_connect_data"` // omitempty breaks this UsersData *UsersData `json:"users_data,omitempty"` TokensData map[int64]TokenData `json:"tokens_data,omitempty"` MachineID uuid.UUID `json:"machine_id,omitempty"` LanDiscovery bool `json:"lan_discovery"` RemoteConfig string `json:"remote_config,omitempty"` RCLastUpdate time.Time `json:"rc_last_update,omitempty"` // Indicates whether the virtual servers are used. True by default VirtualLocation TrueField `json:"virtual_location,omitempty"` }
Config stores application settings and tokens.
Config should be evolved is such a way, that it does not require any use of constructors by the caller.
type ConfigPublisher ¶
type ConfigPublisher interface {
Publish(*Config)
}
type Field ¶
type Field[T any] struct { // contains filtered or unexported fields }
Field will unmarshal to null if unset.
func (Field[T]) MarshalJSON ¶
MarshalJSON has to be a value receiver or else nil f.value will be marshaled as {}.
func (*Field[T]) Set ¶
func (f *Field[T]) Set(value T)
Set the inner value.
Example ¶
var b Field[bool] fmt.Printf("%t\n", b.Get()) b.Set(false) fmt.Printf("%t\n", b.Get()) b.Set(true) fmt.Printf("%t\n", b.Get())
Output: false false true
func (*Field[T]) UnmarshalJSON ¶
UnmarshalJSON has to be a pointer receiver or else f.value will not update.
type FileReader ¶
type FilesystemConfigManager ¶
type FilesystemConfigManager struct { NewInstallation bool // contains filtered or unexported fields }
FilesystemConfigManager implements config persistence and retrieval from disk.
Thread-safe.
func NewFilesystemConfigManager ¶
func NewFilesystemConfigManager(location, vault, salt string, machineIDGetter MachineIDGetter, fsHandle FilesystemHandle, configPublisher ConfigPublisher) *FilesystemConfigManager
NewFilesystemConfigManager is constructed from a given location and salt.
func (*FilesystemConfigManager) Load ¶
func (f *FilesystemConfigManager) Load(c *Config) error
Load encrypted config from the filesystem.
Thread-safe.
func (*FilesystemConfigManager) Reset ¶
func (f *FilesystemConfigManager) Reset() error
Reset config values to defaults.
Thread-safe.
func (*FilesystemConfigManager) SaveWith ¶
func (f *FilesystemConfigManager) SaveWith(fn SaveFunc) error
SaveWith modifications provided by fn.
Thread-safe.
type FilesystemHandle ¶
type HostNameReader ¶
type MachineID ¶
func NewMachineID ¶
func NewMachineID(fileReader FileReader, hostNameReader HostNameReader) *MachineID
func (*MachineID) GetMachineID ¶
func (*MachineID) GetUsedInformationMask ¶
Return the bitmask to identify what information was used to generate the machine ID
type MachineIDGetter ¶
type Manager ¶
type Manager interface { // SaveWith updates parts of the config specified by the SaveFunc. SaveWith(SaveFunc) error // Load config into a given struct. Load(*Config) error // Reset config to default values. Reset() error }
Manager is responsible for persisting and retrieving the config.
type NCData ¶
type NCData struct { UserID uuid.UUID `json:"user_id,omitempty"` Username string `json:"username,omitempty"` Password string `json:"password,omitempty"` Endpoint string `json:"endpoint,omitempty"` ExpirationDate time.Time `json:"timestamp,omitempty"` }
func (*NCData) IsUserIDEmpty ¶
type PortSet ¶
PortSet is a set of ports.
func (PortSet) MarshalJSON ¶
MarshalJSON into []float64.
func (*PortSet) UnmarshalJSON ¶
UnmarshalJSON into map[int64]bool.
type Protocol ¶
type Protocol int32
func (Protocol) Descriptor ¶
func (Protocol) Descriptor() protoreflect.EnumDescriptor
func (Protocol) EnumDescriptor
deprecated
func (Protocol) Number ¶
func (x Protocol) Number() protoreflect.EnumNumber
func (Protocol) Type ¶
func (Protocol) Type() protoreflect.EnumType
type ServerGroup ¶
type ServerGroup int32
const ( ServerGroup_UNDEFINED ServerGroup = 0 ServerGroup_DoubleVPN ServerGroup = 1 ServerGroup_ONION_OVER_VPN ServerGroup = 3 ServerGroup_ULTRA_FAST_TV ServerGroup = 5 ServerGroup_ANTI_DDOS ServerGroup = 7 ServerGroup_DEDICATED_IP ServerGroup = 9 ServerGroup_STANDARD_VPN_SERVERS ServerGroup = 11 ServerGroup_NETFLIX_USA ServerGroup = 13 ServerGroup_P2P ServerGroup = 15 ServerGroup_OBFUSCATED ServerGroup = 17 ServerGroup_EUROPE ServerGroup = 19 ServerGroup_THE_AMERICAS ServerGroup = 21 ServerGroup_ASIA_PACIFIC ServerGroup = 23 ServerGroup_AFRICA_MIDDLE_EAST_INDIA ServerGroup = 25 )
func (ServerGroup) Descriptor ¶
func (ServerGroup) Descriptor() protoreflect.EnumDescriptor
func (ServerGroup) Enum ¶
func (x ServerGroup) Enum() *ServerGroup
func (ServerGroup) EnumDescriptor
deprecated
func (ServerGroup) EnumDescriptor() ([]byte, []int)
Deprecated: Use ServerGroup.Descriptor instead.
func (ServerGroup) Number ¶
func (x ServerGroup) Number() protoreflect.EnumNumber
func (ServerGroup) String ¶
func (x ServerGroup) String() string
func (ServerGroup) Type ¶
func (ServerGroup) Type() protoreflect.EnumType
type StdFilesystemHandle ¶
type StdFilesystemHandle struct { }
func (StdFilesystemHandle) FileExists ¶
func (StdFilesystemHandle) FileExists(location string) bool
type Subnets ¶
Subnets is a set of subnets.
func (Subnets) MarshalJSON ¶
MarshalJSON into []string.
func (*Subnets) UnmarshalJSON ¶
UnmarshalJSON into map[string]bool.
type Technology ¶
type Technology int32
const ( Technology_UNKNOWN_TECHNOLOGY Technology = 0 Technology_OPENVPN Technology = 1 Technology_NORDLYNX Technology = 2 Technology_NORDWHISPER Technology = 3 )
func (Technology) Descriptor ¶
func (Technology) Descriptor() protoreflect.EnumDescriptor
func (Technology) Enum ¶
func (x Technology) Enum() *Technology
func (Technology) EnumDescriptor
deprecated
func (Technology) EnumDescriptor() ([]byte, []int)
Deprecated: Use Technology.Descriptor instead.
func (Technology) Number ¶
func (x Technology) Number() protoreflect.EnumNumber
func (Technology) String ¶
func (x Technology) String() string
func (Technology) Type ¶
func (Technology) Type() protoreflect.EnumType
type TokenData ¶
type TokenData struct { Token string `json:"token,omitempty"` TokenExpiry string `json:"token_expiry,omitempty"` RenewToken string `json:"renew_token,omitempty"` IsOAuth bool `json:"is_oauth,omitempty"` TrustedPassToken string `json:"trusted_pass_token,omitempty"` TrustedPassOwnerID string `json:"trusted_pass_owner_id,omitempty"` ServiceExpiry string `json:"service_expiry,omitempty"` NordLynxPrivateKey string `json:"nordlynx_private_key"` OpenVPNUsername string `json:"openvpn_username"` OpenVPNPassword string `json:"openvpn_password"` NCData NCData `json:"nc_data,omitempty"` IdempotencyKey *uuid.UUID `json:"idempotency_key,omitempty"` }
type UidBoolMap ¶
UidBoolMap is a set of user ids.
func (*UidBoolMap) MarshalJSON ¶
func (n *UidBoolMap) MarshalJSON() ([]byte, error)
MarshalJSON into []float64
func (*UidBoolMap) UnmarshalJSON ¶
func (n *UidBoolMap) UnmarshalJSON(b []byte) error
UnmarshalJSON into map[int64]bool
type UsersData ¶
type UsersData struct { Notify UidBoolMap `json:"notify"` // To be removed in a next major version NotifyOff UidBoolMap `json:"notify_off"` TrayOff UidBoolMap `json:"tray_off"` }
UsersData stores users which will receive notifications and see the tray icon.