diff --git a/ci/generate_protobuf.sh b/ci/generate_protobuf.sh index 5429c7df6..45e9d5348 100755 --- a/ci/generate_protobuf.sh +++ b/ci/generate_protobuf.sh @@ -32,7 +32,6 @@ protoc --go_opt=module=github.com/NordSecurity/nordvpn-linux --go_out=. protobuf protoc --go_opt=module=github.com/NordSecurity/nordvpn-linux --go_out=. protobuf/fileshare/fileshare.proto -I protobuf/fileshare protoc --go_opt=module=github.com/NordSecurity/nordvpn-linux --go_out=. protobuf/snapconf/snapconf.proto -I protobuf/snapconf protoc --go_opt=module=github.com/NordSecurity/nordvpn-linux --go_out=. protobuf/norduser/norduser.proto -I protobuf/norduser -protoc --go_opt=module=github.com/NordSecurity/nordvpn-linux --go_out=. protobuf/daemon/state.proto -I protobuf/daemon protoc --go_opt=module=github.com/NordSecurity/nordvpn-linux --go_out=. protobuf/daemon/quench_hidden.proto -I protobuf/daemon protoc --go_grpc_opt=module=github.com/NordSecurity/nordvpn-linux --go_grpc_out=. protobuf/daemon/service.proto -I protobuf/daemon diff --git a/cmd/daemon/main.go b/cmd/daemon/main.go index 634bc649c..6899b2de8 100644 --- a/cmd/daemon/main.go +++ b/cmd/daemon/main.go @@ -49,7 +49,6 @@ import ( "github.com/NordSecurity/nordvpn-linux/events/meshunsetter" "github.com/NordSecurity/nordvpn-linux/events/refresher" "github.com/NordSecurity/nordvpn-linux/events/subs" - "github.com/NordSecurity/nordvpn-linux/features" grpcmiddleware "github.com/NordSecurity/nordvpn-linux/grpc_middleware" "github.com/NordSecurity/nordvpn-linux/internal" "github.com/NordSecurity/nordvpn-linux/ipv6" @@ -151,13 +150,14 @@ func main() { } // fallback to Nordlynx if quench was enabled in previous installation and is disabled now - if (!features.QuenchEnabled || !quenchEnabled) && cfg.Technology == config.Technology_QUENCH { + if (QuenchEnabled || !quenchEnabled) && cfg.Technology == config.Technology_QUENCH { err := fsystem.SaveWith(func(c config.Config) config.Config { c.Technology = config.Technology_NORDLYNX return c }) - - log.Println(internal.ErrorPrefix, "failed to fallback to Nordlynx tech:", err) + if err != nil { + log.Println(internal.ErrorPrefix, "failed to fallback to Nordlynx tech:", err) + } } // Events diff --git a/cmd/daemon/vpn_factory.go b/cmd/daemon/vpn_factory.go index 9c9fc0449..e6f13071c 100644 --- a/cmd/daemon/vpn_factory.go +++ b/cmd/daemon/vpn_factory.go @@ -23,7 +23,7 @@ func getVpnFactory(eventsDbPath string, fwmark uint32, envIsDev bool, return func(tech config.Technology) (vpn.VPN, error) { switch tech { case config.Technology_NORDLYNX: - return nordlynxVPN, nil + return nordlynxVPN, err case config.Technology_OPENVPN: return openvpn.New(fwmark, eventsPublisher), nil case config.Technology_QUENCH: diff --git a/cmd/daemon/vpn_no_quench.go b/cmd/daemon/vpn_no_quench.go index eaa062759..974630942 100644 --- a/cmd/daemon/vpn_no_quench.go +++ b/cmd/daemon/vpn_no_quench.go @@ -8,6 +8,8 @@ import ( "github.com/NordSecurity/nordvpn-linux/daemon/vpn" ) +const QuenchEnabled = false + func getQuenchVPN(fwmark uint32) (vpn.VPN, error) { return nil, fmt.Errorf("quench is not enabled") } diff --git a/cmd/daemon/vpn_quench.go b/cmd/daemon/vpn_quench.go index 0ee7aabb5..9a8918a10 100644 --- a/cmd/daemon/vpn_quench.go +++ b/cmd/daemon/vpn_quench.go @@ -2,6 +2,8 @@ package main +const QuenchEnabled = true + import "github.com/NordSecurity/nordvpn-linux/daemon/vpn/quench" func getQuenchVPN(fwmark uint32) (*quench.Quench, error) { diff --git a/config/remote/firebase.go b/config/remote/firebase.go index bad41c855..a0253483f 100644 --- a/config/remote/firebase.go +++ b/config/remote/firebase.go @@ -124,7 +124,7 @@ func (rc *RConfig) fetchAndSaveRemoteConfig() (remoteConfig []byte, err error) { return remoteConfigValue, nil } -// GetValue provides value of requested key from remote config +// getValue provides value of requested key from remote config func (rc *RConfig) getValue(cfgKey string) (string, error) { err := rc.fetchRemoteConfigIfTime() if err != nil { @@ -162,6 +162,7 @@ func stringToSemVersion(stringVersion, prefix string) (*semver.Version, error) { return semver.NewVersion(stringVersion) } +// GetQuenchEnabled returns the quench configuration flag from remote config func (rc *RConfig) GetQuenchEnabled(stringVersion string) (bool, error) { rc.mu.Lock() defer rc.mu.Unlock() diff --git a/daemon/rpc_connect.go b/daemon/rpc_connect.go index c520c18f0..66f0ab75e 100644 --- a/daemon/rpc_connect.go +++ b/daemon/rpc_connect.go @@ -55,18 +55,19 @@ func (r *RPC) quenchConfigFallback(cfg config.Config) config.Config { quenchEnabled, err := r.remoteConfigGetter.GetQuenchEnabled(r.version) if err != nil { log.Println(internal.ErrorPrefix, "failed to retrieve remote config for quench:", err) + return cfg } - if features.QuenchEnabled && (quenchEnabled && err == nil) { + if features.QuenchEnabled && quenchEnabled { return cfg } log.Println(internal.DebugPrefix, "user had configured Quench technology, but it was disabled, falling back to NordLynx") - cfg.Technology = config.Technology_QUENCH + cfg.Technology = config.Technology_NORDLYNX r.cm.SaveWith(func(c config.Config) config.Config { - c.Technology = config.Technology_QUENCH + c.Technology = config.Technology_NORDLYNX return c }) diff --git a/daemon/rpc_set_technology.go b/daemon/rpc_set_technology.go index cedd70938..e47ddc709 100644 --- a/daemon/rpc_set_technology.go +++ b/daemon/rpc_set_technology.go @@ -30,7 +30,7 @@ func (r *RPC) SetTechnology(ctx context.Context, in *pb.SetTechnologyRequest) (* if !quenchEnabled { log.Println(internal.ErrorPrefix, - "user rquested a quench technology but the feature is hidden based on remote config flag") + "user requested a quench technology but the feature is hidden based on remote config flag") return &pb.Payload{ Type: internal.CodeFeatureHidden, }, nil diff --git a/daemon/vpn/quench/libquench.go b/daemon/vpn/quench/libquench.go index be31a18fa..8f384f507 100644 --- a/daemon/vpn/quench/libquench.go +++ b/daemon/vpn/quench/libquench.go @@ -16,16 +16,6 @@ import ( "github.com/NordSecurity/nordvpn-linux/tunnel" ) -// Start(context.Context, Credentials, ServerData) error -// Stop() error -// State() State // required because of OpenVPN -// IsActive() bool -// Tun() tunnel.T // required because of OpenVPN -// NetworkChanged() error -// // GetConnectionParameters returns ServerData of current connection and true if connection is established, or empty -// // ServerData and false if it isn't. -// GetConnectionParameters() (ServerData, bool) - const ( vnicName = "qtun" quenchPrefix = "[quench]"