summaryrefslogtreecommitdiff
path: root/src/state.go
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2022-04-20 14:03:39 +0200
committerjwijenbergh <jeroenwijenbergh@protonmail.com>2022-04-20 14:03:39 +0200
commit77c9f266553cbadfd5fb150a26c2162b705f151e (patch)
tree5292c7187cd97dac53674ee2baa4138a3eed7e68 /src/state.go
parent5d3818161f635b82e3289e82ac1ab631f726566b (diff)
FSM: More states and fix graph order
Diffstat (limited to 'src/state.go')
-rw-r--r--src/state.go16
1 files changed, 8 insertions, 8 deletions
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