Documentation ¶
Overview ¶
Package daemon provides gRPC interface for management of vpn on the device and various related functionalities, such as communication with the backend api and configuration management.
Index ¶
- Constants
- Variables
- func GetLatestVersion(versions []semver.Version) semver.Version
- func JobCountries(dm *DataManager, api core.ServersAPI) func() error
- func JobHeartBeat(publisher events.Publisher[time.Duration], period time.Duration) func()
- func JobInsights(dm InsightsDataManager, api core.InsightsAPI, networker interface{ ... }, ...) func()
- func JobServerCheck(dm *DataManager, api core.ServersAPI, netw networker.Networker, ...) func()
- func JobServers(dm *DataManager, cm config.Manager, api core.ServersAPI, validate bool) func() error
- func JobTemplates(cdn core.CDN) func()
- func JobVersionCheck(dm *DataManager, api *RepoAPI) func()
- func ParseDebianVersions(data []byte) []string
- func ParseRpmVersions(data []byte) []string
- func PickServer(api core.ServersAPI, countries core.Countries, servers core.Servers, ...) (core.Server, bool, error)
- func StartNC(prefix string, ncClient nc.NotificationClient)
- func StringsToVersions(v []string) []semver.Version
- type AppData
- type ConnectionParameters
- type CountryData
- type DataManager
- func (dm *DataManager) Cities(countryName string, technology config.Technology, protocol config.Protocol, ...) ([]*pb.ServerGroup, error)
- func (dm *DataManager) Countries(technology config.Technology, protocol config.Protocol, obfuscated bool, ...) ([]*pb.ServerGroup, error)
- func (dm *DataManager) CountryCodeToCountryName(code string) string
- func (dm *DataManager) CountryDataExists() bool
- func (dm *DataManager) GetAppData() AppData
- func (dm *DataManager) GetCountryData() CountryData
- func (dm *DataManager) GetInsightsData() InsightsData
- func (dm *DataManager) GetServersData() ServersData
- func (dm *DataManager) GetVersionData() VersionData
- func (dm *DataManager) Groups(technology config.Technology, protocol config.Protocol, obfuscated bool, ...) ([]*pb.ServerGroup, error)
- func (dm *DataManager) IsCountryDataValid() bool
- func (dm *DataManager) IsServersDataValid() bool
- func (dm *DataManager) LoadData() error
- func (dm *DataManager) ServerDataExists() bool
- func (dm *DataManager) SetCountryData(updatedAt time.Time, countries core.Countries, hash string) error
- func (dm *DataManager) SetInsightsData(insights core.Insights) error
- func (dm *DataManager) SetServerStatus(s core.Server, status core.Status) error
- func (dm *DataManager) SetServersData(updatedAt time.Time, servers core.Servers, hash string) (err error)
- func (dm *DataManager) SetVersionData(version semver.Version, newerAvailable bool)
- func (dm *DataManager) UpdateServerPenalty(s core.Server) error
- type FactoryFunc
- type GetTimeoutFunc
- type InsightsData
- type InsightsDataManager
- type ParametersStorage
- type RPC
- func (r *RPC) AccountInfo(ctx context.Context, _ *pb.Empty) (*pb.AccountResponse, error)
- func (r *RPC) Cities(ctx context.Context, in *pb.CitiesRequest) (*pb.ServerGroupsList, error)
- func (r *RPC) ClaimOnlinePurchase(ctx context.Context, in *pb.Empty) (*pb.ClaimOnlinePurchaseResponse, error)
- func (r *RPC) Connect(in *pb.ConnectRequest, srv pb.Daemon_ConnectServer) (retErr error)
- func (r *RPC) ConnectCancel(_ context.Context, _ *pb.Empty) (*pb.Payload, error)
- func (r *RPC) Countries(ctx context.Context, in *pb.Empty) (*pb.ServerGroupsList, error)
- func (r *RPC) Disconnect(_ *pb.Empty, srv pb.Daemon_DisconnectServer) error
- func (r *RPC) GetServers(ctx context.Context, in *pb.Empty) (*pb.ServersResponse, error)
- func (r *RPC) Groups(ctx context.Context, in *pb.Empty) (*pb.ServerGroupsList, error)
- func (r *RPC) IsLoggedIn(ctx context.Context, _ *pb.Empty) (*pb.Bool, error)
- func (r *RPC) LoginOAuth2(in *pb.LoginOAuth2Request, srv pb.Daemon_LoginOAuth2Server) error
- func (r *RPC) LoginOAuth2Callback(ctx context.Context, in *pb.LoginOAuth2CallbackRequest) (payload *pb.Empty, retErr error)
- func (r *RPC) LoginWithToken(ctx context.Context, in *pb.LoginWithTokenRequest) (*pb.LoginResponse, error)
- func (r *RPC) Logout(ctx context.Context, in *pb.LogoutRequest) (payload *pb.Payload, retErr error)
- func (r *RPC) Ping(ctx context.Context, in *pb.Empty) (*pb.PingResponse, error)
- func (r *RPC) RateConnection(ctx context.Context, in *pb.RateRequest) (*pb.Payload, error)
- func (r *RPC) SetAllowlist(ctx context.Context, in *pb.SetAllowlistRequest) (*pb.Payload, error)
- func (r *RPC) SetAnalytics(ctx context.Context, in *pb.SetGenericRequest) (*pb.Payload, error)
- func (r *RPC) SetAutoConnect(ctx context.Context, in *pb.SetAutoconnectRequest) (*pb.Payload, error)
- func (r *RPC) SetDNS(ctx context.Context, in *pb.SetDNSRequest) (*pb.SetDNSResponse, error)
- func (r *RPC) SetDefaults(ctx context.Context, in *pb.Empty) (*pb.Payload, error)
- func (r *RPC) SetFirewall(ctx context.Context, in *pb.SetGenericRequest) (*pb.Payload, error)
- func (r *RPC) SetFirewallMark(ctx context.Context, in *pb.SetUint32Request) (*pb.Payload, error)
- func (r *RPC) SetIpv6(ctx context.Context, in *pb.SetGenericRequest) (*pb.Payload, error)
- func (r *RPC) SetKillSwitch(ctx context.Context, in *pb.SetKillSwitchRequest) (*pb.Payload, error)
- func (r *RPC) SetLANDiscovery(ctx context.Context, in *pb.SetLANDiscoveryRequest) (*pb.SetLANDiscoveryResponse, error)
- func (r *RPC) SetNotify(ctx context.Context, in *pb.SetNotifyRequest) (*pb.Payload, error)
- func (r *RPC) SetObfuscate(ctx context.Context, in *pb.SetGenericRequest) (*pb.Payload, error)
- func (r *RPC) SetPostQuantum(ctx context.Context, in *pb.SetGenericRequest) (*pb.Payload, error)
- func (r *RPC) SetProtocol(ctx context.Context, in *pb.SetProtocolRequest) (*pb.SetProtocolResponse, error)
- func (r *RPC) SetRouting(ctx context.Context, in *pb.SetGenericRequest) (*pb.Payload, error)
- func (r *RPC) SetTechnology(ctx context.Context, in *pb.SetTechnologyRequest) (*pb.Payload, error)
- func (r *RPC) SetThreatProtectionLite(ctx context.Context, in *pb.SetThreatProtectionLiteRequest) (*pb.SetThreatProtectionLiteResponse, error)
- func (r *RPC) SetTray(ctx context.Context, in *pb.SetTrayRequest) (*pb.Payload, error)
- func (r *RPC) SetVirtualLocation(ctx context.Context, in *pb.SetGenericRequest) (*pb.Payload, error)
- func (r *RPC) Settings(ctx context.Context, in *pb.Empty) (*pb.SettingsResponse, error)
- func (r *RPC) SettingsProtocols(ctx context.Context, _ *pb.Empty) (*pb.Payload, error)
- func (r *RPC) SettingsTechnologies(ctx context.Context, _ *pb.Empty) (*pb.Payload, error)
- func (r *RPC) StartAutoConnect(timeoutFn GetTimeoutFunc) error
- func (r *RPC) StartAutoMeshnet(meshService *meshnet.Server, timeoutFn GetTimeoutFunc) error
- func (r *RPC) StartJobs(statePublisher *state.StatePublisher, ...)
- func (r *RPC) StartKillSwitch()
- func (r *RPC) StartSystemShutdownMonitor()
- func (r *RPC) Status(context.Context, *pb.Empty) (*pb.StatusResponse, error)
- func (r *RPC) StopKillSwitch() error
- func (r *RPC) SubscribeToStateChanges(_ *pb.Empty, srv pb.Daemon_SubscribeToStateChangesServer) error
- func (r *RPC) TokenInfo(ctx context.Context, _ *pb.Empty) (*pb.TokenInfoResponse, error)
- func (r *RPC) UnsetAllAllowlist(ctx context.Context, in *pb.Empty) (*pb.Payload, error)
- func (r *RPC) UnsetAllowlist(ctx context.Context, in *pb.SetAllowlistRequest) (*pb.Payload, error)
- type RepoAPI
- type RepoAPIResponse
- type ServerParameters
- type ServersData
- type VersionData
Constants ¶
const ( // BaseURL defines the base uri for the api BaseURL = "https://api.nordvpn.com" // RepoURL is the url for NordVPN repository RepoURL = "https://repo.nordvpn.com" // RandomComponentMin defines minimal value of random component RandomComponentMin = 0 // RandomComponentMax defines maximum value of random component RandomComponentMax = 0.001 )
const ( Alpha = 0.7 Beta = -0.15 Lambda = 1 K = 0.5 W = 0.5 Fi = 7 )
const (
// R defines earth radius in meters
R = 6371e3
)
Variables ¶
var ( // ServersDataFilePath defines path to servers data file ServersDataFilePath = filepath.Join(internal.DatFilesPathCommon, "servers.dat") // CountryDataFilePath defines path to countries data file CountryDataFilePath = filepath.Join(internal.DatFilesPathCommon, "countries.dat") // InsightsFilePath defines filename of insights file InsightsFilePath = filepath.Join(internal.DatFilesPath, "insights.dat") // VersionFilePath defines filename of latest available version file VersionFilePath = filepath.Join(internal.DatFilesPathCommon, "version.dat") // IconPath defines icon file path IconPath = internal.PrefixCommonPath("/usr/share/icons/hicolor/scalable/apps/nordvpn.svg") )
var ErrDedicatedIPServer = fmt.Errorf("selected dedicated IP servers group")
var ( // ErrMissingExchangeToken is returned when login was successful but // there is not enough data to request the token ErrMissingExchangeToken = errors.New("exchange token not provided") )
Functions ¶
func JobCountries ¶
func JobCountries(dm *DataManager, api core.ServersAPI) func() error
func JobHeartBeat ¶
JobHeartBeat sends heart beats.
func JobInsights ¶
func JobInsights( dm InsightsDataManager, api core.InsightsAPI, networker interface{ IsVPNActive() bool }, events *events.Events, downloader bool, ) func()
JobInsights is responsible for collecting information about the user's physical location. It helps Data Analytics team to deduce country of origin of our users regardless to which country they are connecting.
func JobServerCheck ¶
func JobServerCheck( dm *DataManager, api core.ServersAPI, netw networker.Networker, server core.Server, ) func()
JobServerCheck marks servers as offline if connection to them drops
func JobServers ¶
func JobServers(dm *DataManager, cm config.Manager, api core.ServersAPI, validate bool) func() error
JobServers is responsible for population of local server cache which is needed to avoid excess requests to the backend API.
func JobTemplates ¶
func JobVersionCheck ¶
func JobVersionCheck(dm *DataManager, api *RepoAPI) func()
func ParseDebianVersions ¶
func ParseRpmVersions ¶
func PickServer ¶
func PickServer( api core.ServersAPI, countries core.Countries, servers core.Servers, longitude float64, latitude float64, tech config.Technology, protocol config.Protocol, obfuscated bool, tag string, groupFlag string, allowVirtualServer bool, ) (core.Server, bool, error)
PickServer by the specified criteria.
func StartNC ¶
func StartNC(prefix string, ncClient nc.NotificationClient)
StartNC tries to start notification client and logs any errors if they occur. This is just a convenience wrapper, we always start notification client in another goroutine, so we cannot handle the errors directly in the caller. Prefix will be prepended to the error log.
func StringsToVersions ¶
Types ¶
type ConnectionParameters ¶
type ConnectionParameters struct { ConnectionSource pb.ConnectionSource Parameters ServerParameters }
type CountryData ¶
type DataManager ¶
type DataManager struct {
// contains filtered or unexported fields
}
func NewDataManager ¶
func NewDataManager(insightsFilePath, serversFilePath, countryFilePath, versionFilePath string, dataUpdateEvents *events.DataUpdateEvents) *DataManager
func (*DataManager) Cities ¶
func (dm *DataManager) Cities( countryName string, technology config.Technology, protocol config.Protocol, obfuscated bool, virtualLocation bool, ) ([]*pb.ServerGroup, error)
func (*DataManager) Countries ¶
func (dm *DataManager) Countries( technology config.Technology, protocol config.Protocol, obfuscated bool, virtualLocation bool, ) ([]*pb.ServerGroup, error)
func (*DataManager) CountryCodeToCountryName ¶
func (dm *DataManager) CountryCodeToCountryName(code string) string
CountryCodeToCountryName returns country name for the given country code or an empty string if no match is found.
func (*DataManager) CountryDataExists ¶
func (dm *DataManager) CountryDataExists() bool
func (*DataManager) GetAppData ¶
func (dm *DataManager) GetAppData() AppData
func (*DataManager) GetCountryData ¶
func (dm *DataManager) GetCountryData() CountryData
func (*DataManager) GetInsightsData ¶
func (dm *DataManager) GetInsightsData() InsightsData
func (*DataManager) GetServersData ¶
func (dm *DataManager) GetServersData() ServersData
func (*DataManager) GetVersionData ¶
func (dm *DataManager) GetVersionData() VersionData
func (*DataManager) Groups ¶
func (dm *DataManager) Groups( technology config.Technology, protocol config.Protocol, obfuscated bool, virtualLocation bool, ) ([]*pb.ServerGroup, error)
func (*DataManager) IsCountryDataValid ¶
func (dm *DataManager) IsCountryDataValid() bool
func (*DataManager) IsServersDataValid ¶
func (dm *DataManager) IsServersDataValid() bool
func (*DataManager) LoadData ¶
func (dm *DataManager) LoadData() error
func (*DataManager) ServerDataExists ¶
func (dm *DataManager) ServerDataExists() bool
func (*DataManager) SetCountryData ¶
func (*DataManager) SetInsightsData ¶
func (dm *DataManager) SetInsightsData(insights core.Insights) error
func (*DataManager) SetServerStatus ¶
func (*DataManager) SetServersData ¶
func (*DataManager) SetVersionData ¶
func (dm *DataManager) SetVersionData(version semver.Version, newerAvailable bool)
func (*DataManager) UpdateServerPenalty ¶
func (dm *DataManager) UpdateServerPenalty(s core.Server) error
type FactoryFunc ¶
type FactoryFunc func(config.Technology) (vpn.VPN, error)
type GetTimeoutFunc ¶
type InsightsData ¶
type InsightsDataManager ¶
type InsightsDataManager interface { GetInsightsData() InsightsData SetInsightsData(core.Insights) error }
type ParametersStorage ¶
type ParametersStorage struct {
// contains filtered or unexported fields
}
func (*ParametersStorage) GetConnectionParameters ¶
func (c *ParametersStorage) GetConnectionParameters() (ConnectionParameters, error)
func (*ParametersStorage) SetConnectionParameters ¶
func (c *ParametersStorage) SetConnectionParameters(connectionSource pb.ConnectionSource, parameters ServerParameters)
type RPC ¶
type RPC struct { ConnectionParameters ParametersStorage pb.UnimplementedDaemonServer // contains filtered or unexported fields }
RPC is a gRPC server.
func NewRPC ¶
func NewRPC( environment internal.Environment, ac auth.Checker, cm config.Manager, dm *DataManager, api core.CombinedAPI, serversAPI core.ServersAPI, credentialsAPI core.CredentialsAPI, cdn core.CDN, repo *RepoAPI, authentication core.Authentication, version string, events *daemonevents.Events, factory FactoryFunc, endpointResolver network.EndpointResolver, netw networker.Networker, publisher events.Publisher[string], nameservers dns.Getter, ncClient nc.NotificationClient, analytics events.Analytics, norduser service.Service, meshRegistry mesh.Registry, statePublisher *state.StatePublisher, connectContext *sharedctx.Context, ) *RPC
func (*RPC) AccountInfo ¶
AccountInfo returns user account information.
func (*RPC) Cities ¶
func (r *RPC) Cities(ctx context.Context, in *pb.CitiesRequest) (*pb.ServerGroupsList, error)
Cities provides cities command and autocompletion.
func (*RPC) ClaimOnlinePurchase ¶
func (*RPC) Connect ¶
func (r *RPC) Connect(in *pb.ConnectRequest, srv pb.Daemon_ConnectServer) (retErr error)
Connect initiates and handles the VPN connection process
func (*RPC) ConnectCancel ¶
ConnectCancel cancels an active call for connect to VPN server or meshnet exit node and returns response code immediately without waiting for an actual cancel.
func (*RPC) Disconnect ¶
func (*RPC) GetServers ¶
func (*RPC) IsLoggedIn ¶
func (*RPC) LoginOAuth2 ¶
func (r *RPC) LoginOAuth2(in *pb.LoginOAuth2Request, srv pb.Daemon_LoginOAuth2Server) error
LoginOAuth2 is called when logging in with OAuth2.
func (*RPC) LoginOAuth2Callback ¶
func (r *RPC) LoginOAuth2Callback(ctx context.Context, in *pb.LoginOAuth2CallbackRequest) (payload *pb.Empty, retErr error)
LoginOAuth2Callback is called by the browser via cli during OAuth2 login.
func (*RPC) LoginWithToken ¶
func (r *RPC) LoginWithToken(ctx context.Context, in *pb.LoginWithTokenRequest) (*pb.LoginResponse, error)
Login the user with given token
func (*RPC) RateConnection ¶
func (*RPC) SetAllowlist ¶
func (*RPC) SetAnalytics ¶
SetAnalytics
func (*RPC) SetAutoConnect ¶
func (*RPC) SetDNS ¶
func (r *RPC) SetDNS(ctx context.Context, in *pb.SetDNSRequest) (*pb.SetDNSResponse, error)
func (*RPC) SetDefaults ¶
func (*RPC) SetFirewall ¶
SetFirewall controls whether firewall should be used by the app or not.
This setting impacts the usage of these features: - Killswitch (impacts only next enabling) - Allowlist - Connect (impacts only connections, disconnect still works with the old setting)
func (*RPC) SetFirewallMark ¶
func (*RPC) SetKillSwitch ¶
func (*RPC) SetLANDiscovery ¶
func (r *RPC) SetLANDiscovery(ctx context.Context, in *pb.SetLANDiscoveryRequest) (*pb.SetLANDiscoveryResponse, error)
func (*RPC) SetObfuscate ¶
func (*RPC) SetPostQuantum ¶
func (*RPC) SetProtocol ¶
func (r *RPC) SetProtocol(ctx context.Context, in *pb.SetProtocolRequest) (*pb.SetProtocolResponse, error)
func (*RPC) SetRouting ¶
SetRouting controls whether routing should be used by the app or not.
This setting impacts the usage of these features: - Allowlist - Connect - Meshnet
func (*RPC) SetTechnology ¶
func (*RPC) SetThreatProtectionLite ¶
func (r *RPC) SetThreatProtectionLite( ctx context.Context, in *pb.SetThreatProtectionLiteRequest, ) (*pb.SetThreatProtectionLiteResponse, error)
func (*RPC) SetVirtualLocation ¶
func (*RPC) SettingsProtocols ¶
func (*RPC) SettingsTechnologies ¶
func (*RPC) StartAutoConnect ¶
func (r *RPC) StartAutoConnect(timeoutFn GetTimeoutFunc) error
StartAutoConnect connect to VPN server if autoconnect is enabled
func (*RPC) StartAutoMeshnet ¶
func (r *RPC) StartAutoMeshnet(meshService *meshnet.Server, timeoutFn GetTimeoutFunc) error
StartAutoMeshnet enable meshnet if it was enabled before
func (*RPC) StartKillSwitch ¶
func (r *RPC) StartKillSwitch()
func (*RPC) StartSystemShutdownMonitor ¶
func (r *RPC) StartSystemShutdownMonitor()
StartSystemShutdownMonitor to be run on separate goroutine
func (*RPC) StopKillSwitch ¶
func (*RPC) SubscribeToStateChanges ¶
func (*RPC) UnsetAllAllowlist ¶
func (*RPC) UnsetAllowlist ¶
type RepoAPIResponse ¶
type RepoAPIResponse struct { Headers http.Header Body io.ReadCloser }
type ServerParameters ¶
type ServerParameters struct { Country string City string Group config.ServerGroup }
func GetServerParameters ¶
func GetServerParameters(serverTag string, groupTag string, countries core.Countries) ServerParameters
type ServersData ¶
type VersionData ¶
type VersionData struct {
// contains filtered or unexported fields
}
Source Files ¶
- api_repo.go
- connecton_data.go
- constants.go
- data_manager.go
- data_models.go
- distance.go
- job_appversion.go
- job_countries.go
- job_heartbeat.go
- job_insights.go
- job_server_check.go
- job_servers.go
- job_templates.go
- jobs.go
- nc.go
- penalty.go
- random.go
- rpc.go
- rpc_account.go
- rpc_cities.go
- rpc_claim_online_purchase.go
- rpc_connect.go
- rpc_connect_cancel.go
- rpc_countries.go
- rpc_disconnect.go
- rpc_groups.go
- rpc_login.go
- rpc_logout.go
- rpc_ping.go
- rpc_rate.go
- rpc_servers.go
- rpc_set_allowlist.go
- rpc_set_analytics.go
- rpc_set_autoconnect.go
- rpc_set_defaults.go
- rpc_set_dns.go
- rpc_set_firewall.go
- rpc_set_ipv6.go
- rpc_set_killswitch.go
- rpc_set_lan_discovery.go
- rpc_set_notify.go
- rpc_set_obfuscate.go
- rpc_set_postquantum.go
- rpc_set_protocol.go
- rpc_set_routing.go
- rpc_set_technology.go
- rpc_set_threat_protection_lite.go
- rpc_set_tray.go
- rpc_set_virtual_servers.go
- rpc_settings.go
- rpc_state.go
- rpc_status.go
- rpc_token.go
- servers.go
- versions.go
Directories ¶
Path | Synopsis |
---|---|
Package device provides utilities for querying device information.
|
Package device provides utilities for querying device information. |
Package dns is responsible for configuring dns on various Linux distros.
|
Package dns is responsible for configuring dns on various Linux distros. |
Package firewall provides firewall service to the caller
|
Package firewall provides firewall service to the caller |
allowlist
Package allowlist implements allowlist routing.
|
Package allowlist implements allowlist routing. |
iptables
Package iptables implements iptables firewall agent.
|
Package iptables implements iptables firewall agent. |
notables
Package notables implements noop firewall agent.
|
Package notables implements noop firewall agent. |
Package response provides utilities for processing and validation of NordVPN backend api responses.
|
Package response provides utilities for processing and validation of NordVPN backend api responses. |
Package routes provides route setting functionality.
|
Package routes provides route setting functionality. |
iprule
Package iprule provides Go API for interacting with ip rule.
|
Package iprule provides Go API for interacting with ip rule. |
netlink
Package netlink provides router implementation that uses netlink.
|
Package netlink provides router implementation that uses netlink. |
norouter
Package norouter implements noop router.
|
Package norouter implements noop router. |
norule
Package norule implements noop policy router.
|
Package norule implements noop policy router. |
Package vpn provides interface for vpn management.
|
Package vpn provides interface for vpn management. |
nordlynx
Package nordlynx provides nordlynx vpn technology.
|
Package nordlynx provides nordlynx vpn technology. |
nordlynx/libtelio
Package libtelio wraps generated Go bindings so that the rest of the project would not need C dependencies to run unit tests.
|
Package libtelio wraps generated Go bindings so that the rest of the project would not need C dependencies to run unit tests. |
openvpn
Package openvpn provides OpenVPN technology.
|
Package openvpn provides OpenVPN technology. |