Skip to content

Commit

Permalink
Add autocomplete
Browse files Browse the repository at this point in the history
  • Loading branch information
bartoszWojciechO committed Dec 19, 2024
1 parent e75fa3f commit a744eba
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 27 deletions.
21 changes: 6 additions & 15 deletions daemon/jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"github.com/NordSecurity/nordvpn-linux/daemon/pb"
"github.com/NordSecurity/nordvpn-linux/daemon/state"
"github.com/NordSecurity/nordvpn-linux/events"
"github.com/NordSecurity/nordvpn-linux/features"
"github.com/NordSecurity/nordvpn-linux/internal"
"github.com/NordSecurity/nordvpn-linux/meshnet"

Expand Down Expand Up @@ -234,21 +233,13 @@ func (r *RPC) StartAutoConnect(timeoutFn GetTimeoutFunc) error {
return err
}

if cfg.Technology == config.Technology_NORDWHISPER {
nordWhisperEnabled, err := r.remoteConfigGetter.GetNordWhisperEnabled(r.version)
if cfg.Technology == config.Technology_NORDWHISPER && !r.isNordWhisperEnabled() {
err := r.cm.SaveWith(func(c config.Config) config.Config {
c.Technology = config.Technology_NORDLYNX
return c
})
if err != nil {
log.Println("failed to determine if NordWhisper is enabled:", err)
}

// fallback to Nordlynx if NordWhisper was enabled in previous installation and is disabled now
if features.NordWhisperEnabled || !nordWhisperEnabled {
err := r.cm.SaveWith(func(c config.Config) config.Config {
c.Technology = config.Technology_NORDLYNX
return c
})
if err != nil {
log.Println(internal.ErrorPrefix, "failed to fallback to Nordlynx tech:", err)
}
log.Println(internal.ErrorPrefix, "failed to fallback to Nordlynx tech:", err)
}
}

Expand Down
17 changes: 8 additions & 9 deletions daemon/rpc_is_quench_enabled.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,18 @@ import (

"github.com/NordSecurity/nordvpn-linux/daemon/pb"
"github.com/NordSecurity/nordvpn-linux/features"
"github.com/NordSecurity/nordvpn-linux/internal"
)

func (r *RPC) IsNordWhisperEnabled(ctx context.Context, in *pb.Empty) (*pb.NordWhisperEnabled, error) {
if !features.NordWhisperEnabled {
return &pb.NordWhisperEnabled{Enabled: false}, nil
}
func (r *RPC) isNordWhisperEnabled() bool {
nordWhisperEnabled, err := r.remoteConfigGetter.GetNordWhisperEnabled(r.version)
if err != nil {
log.Println(internal.ErrorPrefix,
"failed to determine if NordWhisper is enabled based on firebase config:", err)
return &pb.NordWhisperEnabled{Enabled: false}, nil
log.Println("failed to determine if NordWhisper is enabled:", err)
return false
}

return &pb.NordWhisperEnabled{Enabled: nordWhisperEnabled}, nil
return features.NordWhisperEnabled && nordWhisperEnabled
}

func (r *RPC) IsNordWhisperEnabled(ctx context.Context, in *pb.Empty) (*pb.NordWhisperEnabled, error) {
return &pb.NordWhisperEnabled{Enabled: r.isNordWhisperEnabled()}, nil
}
12 changes: 9 additions & 3 deletions daemon/rpc_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,16 @@ func (r *RPC) SettingsProtocols(ctx context.Context, _ *pb.Empty) (*pb.Payload,
}

func (r *RPC) SettingsTechnologies(ctx context.Context, _ *pb.Empty) (*pb.Payload, error) {
technologies := []string{
config.Technology_OPENVPN.String(), config.Technology_NORDLYNX.String(),
}

if r.isNordWhisperEnabled() {
technologies = append(technologies, config.Technology_NORDWHISPER.String())
}

return &pb.Payload{
Type: internal.CodeSuccess,
Data: []string{
config.Technology_OPENVPN.String(), config.Technology_NORDLYNX.String(),
},
Data: technologies,
}, nil
}

0 comments on commit a744eba

Please sign in to comment.