summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2022-09-06 13:05:31 +0200
committerjwijenbergh <jeroenwijenbergh@protonmail.com>2022-09-06 13:05:31 +0200
commit55606240f6296ff8238164a6e510ee79722bf5c3 (patch)
tree1bfb729985093d975c94302a9be43552e2078bfb
parentefe37d710cbc8097b02f06e3350f0e8467a23058 (diff)
State + FSM + Python: Rename the HAS_CONFIG state to DISCONNECTED
-rw-r--r--internal/fsm/fsm.go20
-rw-r--r--internal/server/common.go4
-rw-r--r--state.go12
-rw-r--r--wrappers/python/src/state.py2
4 files changed, 19 insertions, 19 deletions
diff --git a/internal/fsm/fsm.go b/internal/fsm/fsm.go
index 74acc50..6178af9 100644
--- a/internal/fsm/fsm.go
+++ b/internal/fsm/fsm.go
@@ -59,8 +59,8 @@ const (
// Ask profile means the go code is asking for a profile selection from the UI
ASK_PROFILE
- // Has config means the user has gotten a config
- HAS_CONFIG
+ // Disconnected means the user has gotten a config for a server but is not connected yet
+ DISCONNECTED
// Disconnecting means the OS is disconnecting and the Go code is doing the /disconnect
DISCONNECTING
@@ -88,8 +88,8 @@ func (s FSMStateID) String() string {
return "Chosen_Server"
case OAUTH_STARTED:
return "OAuth_Started"
- case HAS_CONFIG:
- return "Has_Config"
+ case DISCONNECTED:
+ return "Disconnected"
case REQUEST_CONFIG:
return "Request_Config"
case ASK_PROFILE:
@@ -199,19 +199,19 @@ func (fsm *FSM) Init(
REQUEST_CONFIG: FSMState{
Transitions: []FSMTransition{
{ASK_PROFILE, "Multiple profiles found and no profile chosen"},
- {HAS_CONFIG, "Only one profile or profile already chosen"},
+ {DISCONNECTED, "Only one profile or profile already chosen"},
{NO_SERVER, "Cancel or Error"},
{OAUTH_STARTED, "Re-authorize"},
},
},
ASK_PROFILE: FSMState{
Transitions: []FSMTransition{
- {HAS_CONFIG, "User chooses profile"},
+ {DISCONNECTED, "User chooses profile"},
{NO_SERVER, "Cancel or Error"},
{SEARCH_SERVER, "Cancel or Error"},
},
},
- HAS_CONFIG: FSMState{
+ DISCONNECTED: FSMState{
Transitions: []FSMTransition{
{CONNECTING, "OS reports it is trying to connect"},
{REQUEST_CONFIG, "User reconnects"},
@@ -222,13 +222,13 @@ func (fsm *FSM) Init(
},
DISCONNECTING: FSMState{
Transitions: []FSMTransition{
- {HAS_CONFIG, "Cancel or Error"},
- {HAS_CONFIG, "Done disconnecting"},
+ {DISCONNECTED, "Cancel or Error"},
+ {DISCONNECTED, "Done disconnecting"},
},
},
CONNECTING: FSMState{
Transitions: []FSMTransition{
- {HAS_CONFIG, "Cancel or Error"},
+ {DISCONNECTED, "Cancel or Error"},
{CONNECTED, "Done connecting"},
},
},
diff --git a/internal/server/common.go b/internal/server/common.go
index f6bf67d..c1ce074 100644
--- a/internal/server/common.go
+++ b/internal/server/common.go
@@ -473,12 +473,12 @@ func getConfigWithProfile(server Server, forceTCP bool) (string, string, error)
if baseErr != nil {
return "", "", &types.WrappedErrorMessage{Message: errorMessage, Err: baseErr}
}
- if !base.FSM.HasTransition(fsm.HAS_CONFIG) {
+ if !base.FSM.HasTransition(fsm.DISCONNECTED) {
return "", "", &types.WrappedErrorMessage{
Message: errorMessage,
Err: fsm.WrongStateTransitionError{
Got: base.FSM.Current,
- Want: fsm.HAS_CONFIG,
+ Want: fsm.DISCONNECTED,
}.CustomError(),
}
}
diff --git a/state.go b/state.go
index 884c871..2e0eb04 100644
--- a/state.go
+++ b/state.go
@@ -152,7 +152,7 @@ func (state *VPNState) getConfig(
}
// Signal the server display info
- state.FSM.GoTransitionWithData(fsm.HAS_CONFIG, state.getServerInfoData(), false)
+ state.FSM.GoTransitionWithData(fsm.DISCONNECTED, state.getServerInfoData(), false)
// Save the config
state.Config.Save(&state)
@@ -522,16 +522,16 @@ func (state *VPNState) SetDisconnecting() error {
func (state *VPNState) SetDisconnected(cleanup bool) error {
errorMessage := "failed to set disconnected"
- if state.InFSMState(fsm.HAS_CONFIG) {
+ if state.InFSMState(fsm.DISCONNECTED) {
// already disconnected, show no error
return nil
}
- if !state.FSM.HasTransition(fsm.HAS_CONFIG) {
+ if !state.FSM.HasTransition(fsm.DISCONNECTED) {
return &types.WrappedErrorMessage{
Message: errorMessage,
Err: fsm.WrongStateTransitionError{
Got: state.FSM.Current,
- Want: fsm.HAS_CONFIG,
+ Want: fsm.DISCONNECTED,
}.CustomError(),
}
}
@@ -555,7 +555,7 @@ func (state *VPNState) SetDisconnected(cleanup bool) error {
server.Disconnect(currentServer)
}
- state.FSM.GoTransitionWithData(fsm.HAS_CONFIG, state.getServerInfoData(), false)
+ state.FSM.GoTransitionWithData(fsm.DISCONNECTED, state.getServerInfoData(), false)
return nil
}
@@ -598,7 +598,7 @@ func (state *VPNState) RenewSession() error {
}
func (state *VPNState) ShouldRenewButton() bool {
- if !state.InFSMState(fsm.CONNECTED) && !state.InFSMState(fsm.CONNECTING) && !state.InFSMState(fsm.HAS_CONFIG) && !state.InFSMState(fsm.DISCONNECTING) {
+ if !state.InFSMState(fsm.CONNECTED) && !state.InFSMState(fsm.CONNECTING) && !state.InFSMState(fsm.DISCONNECTED) && !state.InFSMState(fsm.DISCONNECTING) {
return false
}
diff --git a/wrappers/python/src/state.py b/wrappers/python/src/state.py
index a4b11a8..5af004f 100644
--- a/wrappers/python/src/state.py
+++ b/wrappers/python/src/state.py
@@ -18,7 +18,7 @@ class State(IntEnum):
AUTHORIZED = 7
REQUEST_CONFIG = 8
ASK_PROFILE = 9
- HAS_CONFIG = 10
+ DISCONNECTED = 10
DISCONNECTING = 11
CONNECTING = 12
CONNECTED = 13