summaryrefslogtreecommitdiff
path: root/state.go
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2022-09-06 16:53:44 +0200
committerjwijenbergh <jeroenwijenbergh@protonmail.com>2022-09-06 16:53:44 +0200
commit0c3496ac6833416c600cf73569842595ff305cdc (patch)
tree4f6942018ba27b492c7adb6f2dc31236d0d84aff /state.go
parent55606240f6296ff8238164a6e510ee79722bf5c3 (diff)
State: Log fatal discovery errors if the app will fail to work
Diffstat (limited to 'state.go')
-rw-r--r--state.go32
1 files changed, 16 insertions, 16 deletions
diff --git a/state.go b/state.go
index 2e0eb04..c949753 100644
--- a/state.go
+++ b/state.go
@@ -79,11 +79,23 @@ func (state *VPNState) Register(
state.Logger.Log(log.LOG_INFO, "Previous configuration not found")
}
- // Go to the No Server state with the saved servers
- state.FSM.GoTransitionWithData(fsm.NO_SERVER, state.GetSavedServers(), false)
+ discoServers, discoServersErr := state.GetDiscoServers()
+
+ _, currentServerErr := state.Servers.GetCurrentServer()
+ // TODO: Log the error always
+ // Only actually return the error if we have no disco servers and no current server
+ if discoServersErr != nil && discoServers == "" && currentServerErr != nil {
+ return &types.WrappedErrorMessage{Message: errorMessage, Err: discoServersErr}
+ }
+ discoOrgs, discoOrgsErr := state.GetDiscoOrganizations()
- state.GetDiscoServers()
- state.GetDiscoOrganizations()
+ // TODO: Log the error always
+ // Only actually return the error if we have no disco servers and no current server
+ if discoOrgsErr != nil && discoOrgs == "" && currentServerErr != nil {
+ return &types.WrappedErrorMessage{Message: errorMessage, Err: discoOrgsErr}
+ }
+ // Go to the No Server state with the saved servers
+ state.FSM.GoTransitionWithData(fsm.NO_SERVER, state.GetSavedServers(), true)
return nil
}
@@ -407,22 +419,10 @@ func (state *VPNState) ChangeSecureLocation() error {
}
func (state *VPNState) GetDiscoOrganizations() (string, error) {
- if state.InFSMState(fsm.DEREGISTERED) {
- return "", &types.WrappedErrorMessage{
- Message: "failed to get the organizations with Discovery",
- Err: fsm.DeregisteredError{}.CustomError(),
- }
- }
return state.Discovery.GetOrganizationsList()
}
func (state *VPNState) GetDiscoServers() (string, error) {
- if state.InFSMState(fsm.DEREGISTERED) {
- return "", &types.WrappedErrorMessage{
- Message: "failed to get the servers with Discovery",
- Err: fsm.DeregisteredError{}.CustomError(),
- }
- }
return state.Discovery.GetServersList()
}