summaryrefslogtreecommitdiff
path: root/state.go
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2022-05-13 12:12:22 +0200
committerjwijenbergh <jeroenwijenbergh@protonmail.com>2022-05-13 12:12:22 +0200
commit5abf00ab87a55662eefc7716de52ead9749293c6 (patch)
tree1cfa64b99482d7cc08b1d7da5d6833b75f5f7714 /state.go
parent57d6c2ac55a5fd1ea609c873d5410174b7cf6ca4 (diff)
Refactor: Adapt the API to the documentation
Diffstat (limited to 'state.go')
-rw-r--r--state.go21
1 files changed, 10 insertions, 11 deletions
diff --git a/state.go b/state.go
index 64146c8..aa4a53c 100644
--- a/state.go
+++ b/state.go
@@ -100,22 +100,21 @@ func (state *VPNState) chooseServer(url string, isSecureInternet bool) (internal
return server, nil
}
-func (state *VPNState) getConfigWithOptions(url string, isSecureInternet bool, forceTCP bool) (string, error) {
- // FIXME: Do something with force tcp
+func (state *VPNState) getConfigWithOptions(url string, isSecureInternet bool, forceTCP bool) (string, string, error) {
if state.FSM.InState(internal.DEREGISTERED) {
- return "", &StateFSMNotRegisteredError{}
+ return "", "", &StateFSMNotRegisteredError{}
}
// Go to no server if possible, else return an error
if !state.FSM.InState(internal.NO_SERVER) && !state.FSM.GoTransition(internal.NO_SERVER) {
- return "", &internal.FSMWrongStateTransitionError{Got: state.FSM.Current, Want: internal.NO_SERVER}
+ return "", "", &internal.FSMWrongStateTransitionError{Got: state.FSM.Current, Want: internal.NO_SERVER}
}
// Make sure the server is chosen
server, serverErr := state.chooseServer(url, isSecureInternet)
if serverErr != nil {
- return "", &StateConnectError{URL: url, IsSecureInternet: isSecureInternet, Err: serverErr}
+ return "", "", &StateConnectError{URL: url, IsSecureInternet: isSecureInternet, Err: serverErr}
}
// Relogin with oauth
// This moves the state to authorized
@@ -126,7 +125,7 @@ func (state *VPNState) getConfigWithOptions(url string, isSecureInternet bool, f
// We are possibly in oauth started
// So go to no server
state.FSM.GoTransition(internal.NO_SERVER)
- return "", &StateConnectError{URL: url, IsSecureInternet: isSecureInternet, Err: loginErr}
+ return "", "", &StateConnectError{URL: url, IsSecureInternet: isSecureInternet, Err: loginErr}
}
} else { // OAuth was valid, ensure we are in the authorized state
state.FSM.GoTransition(internal.AUTHORIZED)
@@ -134,24 +133,24 @@ func (state *VPNState) getConfigWithOptions(url string, isSecureInternet bool, f
state.FSM.GoTransition(internal.REQUEST_CONFIG)
- config, configErr := internal.GetConfig(server, forceTCP)
+ config, configType, configErr := internal.GetConfig(server, forceTCP)
if configErr != nil {
// Go back to no server if possible
state.FSM.GoTransition(internal.NO_SERVER)
- return "", &StateConnectError{URL: url, IsSecureInternet: isSecureInternet, Err: configErr}
+ return "", "", &StateConnectError{URL: url, IsSecureInternet: isSecureInternet, Err: configErr}
} else {
state.FSM.GoTransition(internal.HAS_CONFIG)
}
- return config, nil
+ return config, configType, nil
}
-func (state *VPNState) GetConfigInstituteAccess(url string, forceTCP bool) (string, error) {
+func (state *VPNState) GetConfigInstituteAccess(url string, forceTCP bool) (string, string, error) {
return state.getConfigWithOptions(url, false, forceTCP)
}
-func (state *VPNState) GetConfigSecureInternet(url string, forceTCP bool) (string, error) {
+func (state *VPNState) GetConfigSecureInternet(url string, forceTCP bool) (string, string, error) {
return state.getConfigWithOptions(url, true, forceTCP)
}