Documentation ¶
Overview ¶
Package config provides functions for managing configuration of the daemon application.
Index ¶
- Variables
- type Allowlist
- type AutoConnectData
- type Config
- type DNS
- type Field
- type FilesystemConfigManager
- type FilesystemHandle
- type LinuxMachineIDGetter
- type MachineIDGetter
- type Manager
- type NCData
- type Notify
- type PortSet
- type Ports
- type Protocol
- type SaveFunc
- type ServerGroup
- type StdFilesystemHandle
- type Subnets
- type Technology
- type TokenData
- type TrueField
- type UsersData
Examples ¶
Constants ¶
This section is empty.
Variables ¶
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", } Protocol_value = map[string]int32{ "UNKNOWN_PROTOCOL": 0, "UDP": 1, "TCP": 2, } )
Enum value maps for Protocol.
var ( Technology_name = map[int32]string{ 0: "UNKNOWN_TECHNOLOGY", 1: "OPENVPN", 2: "NORDLYNX", } Technology_value = map[string]int32{ "UNKNOWN_TECHNOLOGY": 0, "OPENVPN": 1, "NORDLYNX": 2, } )
Enum value maps for Technology.
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": DoubleVPN, "onion_over_vpn": OnionOverVPN, "dedicated_ip": DedicatedIP, "standard_vpn_servers": StandardVPNServers, "p2p": P2P, "europe": Europe, "the_americas": TheAmericas, "asia_pacific": AsiaPacific, "africa_the_middle_east_and_india": AfricaMiddleEastIndia, "obfuscated_servers": Obfuscated, }
GroupMap maps group titles to IDs
Functions ¶
This section is empty.
Types ¶
type AutoConnectData ¶
type AutoConnectData struct { ID int64 `json:"id,omitempty"` ServerTag string `json:"server_tag,omitempty"` 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"` }
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"` }
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 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 FilesystemConfigManager ¶
type FilesystemConfigManager struct {
// 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) *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 LinuxMachineIDGetter ¶
type LinuxMachineIDGetter struct { }
func (LinuxMachineIDGetter) GetMachineID ¶
func (LinuxMachineIDGetter) GetMachineID() uuid.UUID
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"` }
func (*NCData) IsUserIDEmpty ¶
type Notify ¶
Notify is a set of user ids.
func (*Notify) MarshalJSON ¶
MarshalJSON into []float64
func (*Notify) UnmarshalJSON ¶
UnmarshalJSON into map[int64]bool
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 int64
ServerGroup represents a server group type
This should be in the core package, but cannot be there due to import cycles because of dimensions package.
const ( // UndefinedGroup represents non existing server group UndefinedGroup ServerGroup = 0 // DoubleVPN represents the double vpn server group DoubleVPN ServerGroup = 1 // OnionOverVPN represents a OnionOverVPN server group OnionOverVPN ServerGroup = 3 // UltraFastTV represents a UltraFastTV server group UltraFastTV ServerGroup = 5 // AntiDDoS represents an AntiDDoS server group AntiDDoS ServerGroup = 7 // DedicatedIP servers represents the Dedicated IP servers DedicatedIP ServerGroup = 9 // StandardVPNServers represents a StandardVPNServers group StandardVPNServers ServerGroup = 11 // NetflixUSA represents a NetflixUSA server group NetflixUSA ServerGroup = 13 // P2P represents a P2P server group P2P ServerGroup = 15 // Obfuscated represents an Obfuscated server group Obfuscated ServerGroup = 17 // Europe servers represents the European servers Europe ServerGroup = 19 // TheAmericas represents TheAmericas servers TheAmericas ServerGroup = 21 // AsiaPacific represents a AsiaPacific server group AsiaPacific ServerGroup = 23 // AfricaMiddleEastIndia represents a Africa, the Middle East and India server group AfricaMiddleEastIndia ServerGroup = 25 )
type StdFilesystemHandle ¶
type StdFilesystemHandle struct { }
func (StdFilesystemHandle) CreateFile ¶
func (StdFilesystemHandle) CreateFile(location string, mode fs.FileMode) error
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 )
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"` 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"` }