From 77c9f266553cbadfd5fb150a26c2162b705f151e Mon Sep 17 00:00:00 2001 From: jwijenbergh Date: Wed, 20 Apr 2022 14:03:39 +0200 Subject: FSM: More states and fix graph order --- src/state.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/state.go') diff --git a/src/state.go b/src/state.go index 95bb75c..b9bb920 100644 --- a/src/state.go +++ b/src/state.go @@ -6,10 +6,10 @@ import ( type VPNState struct { // Info passed by the client - ConfigDirectory string `json:"-"` - Name string `json:"-"` - StateCallback func(string, string, string) string `json:"-"` - StateCallbackData string `json:"-"` + ConfigDirectory string `json:"-"` + Name string `json:"-"` + StateCallback func(string, string, string) string `json:"-"` + StateCallbackData string `json:"-"` // The chosen server Server *Server `json:"server"` @@ -93,14 +93,14 @@ func (state *VPNState) Connect(url string) (string, error) { state.GoTransition(AUTHENTICATED, "") } + state.GoTransition(REQUEST_CONFIG, "") + config, configErr := state.Server.GetConfig() if configErr != nil { return "", configErr - } - - if !state.HasTransition(CONNECTED) { - return "", errors.New("cannot connect to server, invalid state") + } else { + state.GoTransition(HAS_CONFIG, "") } return config, nil -- cgit v1.2.3