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 Connect(events chan ConnectEvent, creds vpn.Credentials, serverData vpn.ServerData, ...)
- func GetLatestVersion(versions []semver.Version) semver.Version
- func JobCountries(dm *DataManager, api core.ServersAPI) func() error
- func JobHeartBeat(timePeriod int, events *Events) func()
- func JobInsights(dm InsightsDataManager, api core.InsightsAPI, networker interface{ ... }, ...) func()
- func JobServerCheck(dm *DataManager, api core.CombinedAPI, 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 SetAppData(dm *DataManager, tech config.Technology, servers core.Servers)
- func StartNC(prefix string, ncClient nc.NotificationClient)
- func StringsToVersions(v []string) []semver.Version
- type AppData
- type ConnectEvent
- type CountryData
- type DataManager
- 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) IsCountryDataValid() bool
- func (dm *DataManager) IsServersDataValid() bool
- func (dm *DataManager) LoadData() error
- func (dm *DataManager) ServerDataExists() bool
- func (dm *DataManager) SetAppData(countryNames map[bool]map[config.Protocol]mapset.Set[string], ...)
- 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) error
- func (dm *DataManager) SetVersionData(version semver.Version, newerAvailable bool)
- func (dm *DataManager) UpdateServerPenalty(s core.Server) error
- type Events
- type FactoryFunc
- type GetTimeoutFunc
- type InsightsData
- type InsightsDataManager
- type Publisher
- 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.Payload, error)
- func (r *RPC) Connect(in *pb.ConnectRequest, srv pb.Daemon_ConnectServer) (retErr error)
- func (r *RPC) Countries(ctx context.Context, in *pb.Empty) (*pb.Payload, error)
- func (r *RPC) Disconnect(_ *pb.Empty, srv pb.Daemon_DisconnectServer) error
- func (r *RPC) Groups(ctx context.Context, in *pb.Empty) (*pb.Payload, error)
- func (r *RPC) IsLoggedIn(ctx context.Context, _ *pb.Empty) (*pb.Bool, error)
- func (r *RPC) LoginOAuth2(in *pb.Empty, srv pb.Daemon_LoginOAuth2Server) error
- func (r *RPC) LoginOAuth2Callback(ctx context.Context, in *pb.String) (*pb.Empty, error)
- func (r *RPC) LoginWithToken(ctx context.Context, in *pb.LoginWithTokenRequest) (*pb.LoginResponse, error)
- func (r *RPC) Logout(ctx context.Context, in *pb.LogoutRequest) (*pb.Payload, error)
- func (r *RPC) Ping(ctx context.Context, in *pb.Empty) (*pb.Payload, error)
- func (r *RPC) Plans(ctx context.Context, in *pb.Empty) (*pb.PlansResponse, error)
- func (r *RPC) RateConnection(ctx context.Context, in *pb.RateRequest) (*pb.Payload, error)
- func (r *RPC) Register(ctx context.Context, in *pb.RegisterRequest) (*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) 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) Settings(ctx context.Context, in *pb.SettingsRequest) (*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()
- func (r *RPC) StartKillSwitch()
- func (r *RPC) Status(context.Context, *pb.Empty) (*pb.StatusResponse, error)
- func (r *RPC) StopKillSwitch() error
- func (r *RPC) TokenInfo(ctx context.Context, _ *pb.Empty) (*pb.TokenInfoResponse, error)
- type RepoAPI
- type RepoAPIResponse
- type ServersData
- type ServiceEvents
- type ServicePublisher
- type SettingsEvents
- type SettingsPublisher
- 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 ( // 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 Connect ¶
func Connect( events chan ConnectEvent, creds vpn.Credentials, serverData vpn.ServerData, allowlist config.Allowlist, nameservers []string, netw networker.Networker, )
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 }, 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.CombinedAPI, 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 excees 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, ) (core.Server, bool, error)
PickServer by the specified criteria.
func SetAppData ¶
func SetAppData(dm *DataManager, tech config.Technology, servers core.Servers)
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 ConnectEvent ¶
type CountryData ¶
type DataManager ¶
type DataManager struct {
// contains filtered or unexported fields
}
func NewDataManager ¶
func NewDataManager(insightsFilePath, serversFilePath, countryFilePath, versionFilePath string) *DataManager
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) 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) SetAppData ¶
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 Events ¶
type Events struct { Settings *SettingsEvents Service *ServiceEvents }
func NewEvents ¶
func NewEvents( killswitch events.PublishSubcriber[bool], autoconnect events.PublishSubcriber[bool], dns events.PublishSubcriber[events.DataDNS], tplite events.PublishSubcriber[bool], protocol events.PublishSubcriber[config.Protocol], allowlist events.PublishSubcriber[events.DataAllowlist], technology events.PublishSubcriber[config.Technology], obfuscate events.PublishSubcriber[bool], firewall events.PublishSubcriber[bool], routing events.PublishSubcriber[bool], analytics events.PublishSubcriber[bool], notify events.PublishSubcriber[bool], meshnet events.PublishSubcriber[bool], ipv6 events.PublishSubcriber[bool], defaults events.PublishSubcriber[any], connect events.PublishSubcriber[events.DataConnect], disconnect events.PublishSubcriber[events.DataDisconnect], login events.PublishSubcriber[any], accountCheck events.PublishSubcriber[core.ServicesResponse], rate events.PublishSubcriber[events.ServerRating], heartBeat events.PublishSubcriber[int], ) *Events
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 Publisher ¶
type Publisher interface { SettingsPublisher ServicePublisher }
type RPC ¶
type RPC struct { 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, fw firewall.Service, events *Events, factory FactoryFunc, endpointResolver network.EndpointResolver, netw networker.Networker, publisher events.Publisher[string], nameservers dns.Getter, ncClient nc.NotificationClient, analytics events.Analytics, norduser service.NorduserService, meshRegistry mesh.Registry, ) *RPC
func (*RPC) AccountInfo ¶
AccountInfo returns user account information.
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) Disconnect ¶
func (*RPC) IsLoggedIn ¶
func (*RPC) LoginOAuth2 ¶
LoginOAuth2 is called when logging in with OAuth2.
func (*RPC) LoginOAuth2Callback ¶
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) 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) Settings ¶
func (r *RPC) Settings(ctx context.Context, in *pb.SettingsRequest) (*pb.SettingsResponse, error)
Settings returns system daemon settings
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) StopKillSwitch ¶
type RepoAPIResponse ¶
type RepoAPIResponse struct { Headers http.Header Body io.ReadCloser }
type ServersData ¶
type ServiceEvents ¶
type ServiceEvents struct { Connect events.PublishSubcriber[events.DataConnect] Disconnect events.PublishSubcriber[events.DataDisconnect] Login events.PublishSubcriber[any] AccountCheck events.PublishSubcriber[core.ServicesResponse] Rate events.PublishSubcriber[events.ServerRating] HeartBeat events.PublishSubcriber[int] }
func (*ServiceEvents) Subscribe ¶
func (s *ServiceEvents) Subscribe(to ServicePublisher)
type ServicePublisher ¶
type ServicePublisher interface { NotifyConnect(events.DataConnect) error NotifyDisconnect(events.DataDisconnect) error NotifyLogin(any) error NotifyAccountCheck(core.ServicesResponse) error NotifyRate(events.ServerRating) error NotifyHeartBeat(int) error }
type SettingsEvents ¶
type SettingsEvents struct { Killswitch events.PublishSubcriber[bool] Autoconnect events.PublishSubcriber[bool] DNS events.PublishSubcriber[events.DataDNS] ThreatProtectionLite events.PublishSubcriber[bool] Protocol events.PublishSubcriber[config.Protocol] Allowlist events.PublishSubcriber[events.DataAllowlist] Technology events.PublishSubcriber[config.Technology] Obfuscate events.PublishSubcriber[bool] Firewall events.PublishSubcriber[bool] Routing events.PublishSubcriber[bool] Notify events.PublishSubcriber[bool] Meshnet events.PublishSubcriber[bool] Ipv6 events.PublishSubcriber[bool] Defaults events.PublishSubcriber[any] }
func (*SettingsEvents) Publish ¶
func (s *SettingsEvents) Publish(cfg config.Config)
func (*SettingsEvents) Subscribe ¶
func (s *SettingsEvents) Subscribe(to SettingsPublisher)
type SettingsPublisher ¶
type SettingsPublisher interface { NotifyKillswitch(bool) error NotifyAutoconnect(bool) error NotifyDNS(events.DataDNS) error NotifyThreatProtectionLite(bool) error NotifyProtocol(config.Protocol) error NotifyAllowlist(events.DataAllowlist) error NotifyTechnology(config.Technology) error NotifyObfuscate(bool) error NotifyFirewall(bool) error NotifyRouting(bool) error NotifyNotify(bool) error NotifyMeshnet(bool) error NotifyIpv6(bool) error NotifyDefaults(any) error }
type VersionData ¶
type VersionData struct {
// contains filtered or unexported fields
}
Source Files ¶
- allowlist_lan.go
- api_repo.go
- connect.go
- constants.go
- data_manager.go
- data_models.go
- distance.go
- events.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_connect.go
- rpc_countries.go
- rpc_disconnect.go
- rpc_groups.go
- rpc_login.go
- rpc_logout.go
- rpc_ping.go
- rpc_plans.go
- rpc_rate.go
- rpc_register.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_protocol.go
- rpc_set_routing.go
- rpc_set_technology.go
- rpc_set_threat_protection_lite.go
- rpc_settings.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. |
iprouter
Package iprouter provides Go API for interacting with ip route.
|
Package iprouter provides Go API for interacting with ip route. |
iprule
Package iprule provides Go API for interacting with ip rule.
|
Package iprule provides Go API for interacting with ip rule. |
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. |