From 723ecacc8528be0e96db42392f1781ddf5894bea Mon Sep 17 00:00:00 2001 From: Jeroen Wijenbergh Date: Tue, 19 Apr 2022 15:02:45 +0200 Subject: Profiles: Implement basic functionality for sending a profile_id --- src/fsm.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/fsm.go') diff --git a/src/fsm.go b/src/fsm.go index 0ed7a37..7a54fd8 100644 --- a/src/fsm.go +++ b/src/fsm.go @@ -23,6 +23,9 @@ const ( // Authenticated means the OAuth process has finished and the user is now authenticated with the server AUTHENTICATED + // Ask profile means the go code is asking for a profile selection from the ui + ASK_PROFILE + // Connected means the user has been connected to the server CONNECTED ) @@ -37,6 +40,8 @@ func (s FSMStateID) String() string { return "Chosen_Server" case OAUTH_STARTED: return "OAuth_Started" + case ASK_PROFILE: + return "Ask_Profile" case AUTHENTICATED: return "Authenticated" case CONNECTED: @@ -88,19 +93,21 @@ func (eduvpn *VPNState) writeGraph() { f.WriteString(graph) } -func (eduvpn *VPNState) GoTransition(newState FSMStateID, data string) bool { +func (eduvpn *VPNState) GoTransition(newState FSMStateID, data string) (bool, string) { ok := eduvpn.HasTransition(newState) + received := "" + if ok { oldState := eduvpn.FSM.Current eduvpn.FSM.Current = newState if eduvpn.Debug { eduvpn.writeGraph() } - eduvpn.StateCallback(oldState.String(), newState.String(), data) + received = eduvpn.StateCallback(oldState.String(), newState.String(), data) } - return ok + return ok, received } func (eduvpn *VPNState) generateDotGraph() string { @@ -141,7 +148,8 @@ func (eduvpn *VPNState) InitializeFSM() { NO_SERVER: {{CHOSEN_SERVER, "User chooses a server"}}, CHOSEN_SERVER: {{AUTHENTICATED, "Found tokens in config"}, {OAUTH_STARTED, "No tokens found in config"}}, OAUTH_STARTED: {{AUTHENTICATED, "User authorizes with browser"}}, - AUTHENTICATED: {{CONNECTED, "OS reports connected"}, {OAUTH_STARTED, "Re-authenticate with OAuth"}}, + AUTHENTICATED: {{CONNECTED, "OS reports connected"}, {OAUTH_STARTED, "Re-authenticate with OAuth"}, {ASK_PROFILE, "Connect, multiple profiles detected"}}, + ASK_PROFILE: {{CONNECTED, "OS reports connected"}}, CONNECTED: {{AUTHENTICATED, "OS reports disconnected"}}, }, Current: DEREGISTERED, -- cgit v1.2.3