summaryrefslogtreecommitdiff
path: root/state.go
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2022-07-07 16:18:03 +0200
committerjwijenbergh <jeroenwijenbergh@protonmail.com>2022-07-07 16:18:03 +0200
commitc67b8f64438d439d52a9e4955ff1bdf30363dbb1 (patch)
treed54cc9b11bc5cfd9cfef375f4742987193050658 /state.go
parent7d67ce7f6a15970677b7d0b8f4912fe379862515 (diff)
Secure Internet: Implement the Ask Location transition callback
Diffstat (limited to 'state.go')
-rw-r--r--state.go16
1 files changed, 13 insertions, 3 deletions
diff --git a/state.go b/state.go
index 46bee4d..552a5ea 100644
--- a/state.go
+++ b/state.go
@@ -133,16 +133,26 @@ func (state *VPNState) getConfig(chosenServer server.Server, forceTCP bool) (str
return config, configType, nil
}
-func (state *VPNState) AskSecureLocation() error {
- fmt.Println("locations: ", state.Discovery.GetSecureLocationList())
- server, serverErr := state.Discovery.GetServerByCountryCode("NL", "secure_internet")
+func (state *VPNState) SetSecureLocation(countryCode string) error {
+ server, serverErr := state.Discovery.GetServerByCountryCode(countryCode, "secure_internet")
if serverErr != nil {
return &types.WrappedErrorMessage{Message: "failed asking secure location", Err: serverErr}
}
state.Servers.SetSecureLocation(server, &state.FSM, &state.Logger)
+ return nil
+}
+
+func (state *VPNState) AskSecureLocation() error {
+ errorMessage := "failed asking Secure Internet location"
+ locations, locationsErr := state.Discovery.GetSecureLocationList()
+ if locationsErr != nil {
+ return &types.WrappedErrorMessage{Message: errorMessage, Err: locationsErr}
+ }
+ // Ask for the location in the callback
+ state.FSM.GoTransitionWithData(fsm.ASK_LOCATION, locations, false)
return nil
}