diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-07-07 16:18:03 +0200 |
|---|---|---|
| committer | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-07-07 16:18:03 +0200 |
| commit | c67b8f64438d439d52a9e4955ff1bdf30363dbb1 (patch) | |
| tree | d54cc9b11bc5cfd9cfef375f4742987193050658 /state.go | |
| parent | 7d67ce7f6a15970677b7d0b8f4912fe379862515 (diff) | |
Secure Internet: Implement the Ask Location transition callback
Diffstat (limited to 'state.go')
| -rw-r--r-- | state.go | 16 |
1 files changed, 13 insertions, 3 deletions
@@ -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 } |
