diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-08-15 14:41:28 +0200 |
|---|---|---|
| committer | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-08-15 14:41:28 +0200 |
| commit | fec6ea1eba9cee325bbd9d82aa71b8ebf5ef90b0 (patch) | |
| tree | dec0894380a2de8721a1e7733d75053bcc5181fc /cmd/cli | |
| parent | c5e85ba79d4d091af9873f1fb0e7415c3b17b9f8 (diff) | |
Refactor: Use constants for state callbacks instead of strings
Diffstat (limited to 'cmd/cli')
| -rw-r--r-- | cmd/cli/main.go | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/cmd/cli/main.go b/cmd/cli/main.go index 3c262a0..80f4baf 100644 --- a/cmd/cli/main.go +++ b/cmd/cli/main.go @@ -11,6 +11,7 @@ import ( "strings" "github.com/jwijenbergh/eduvpn-common" + "github.com/jwijenbergh/eduvpn-common/internal/fsm" ) type ServerTypes int8 @@ -86,12 +87,13 @@ func sendProfile(state *eduvpn.VPNState, data string) { // If OAuth is started we open the browser with the Auth URL // If we ask for a profile, we send the profile using command line input // Note that this has an additional argument, the vpn state which was wrapped into this callback function below -func stateCallback(state *eduvpn.VPNState, oldState string, newState string, data string) { - if newState == "OAuth_Started" { +func stateCallback(state *eduvpn.VPNState, oldState eduvpn.VPNStateID, newState eduvpn.VPNStateID, data string) { + // TODO: Remove internal usage of fsm + if newState == fsm.OAUTH_STARTED { openBrowser(data) } - if newState == "Ask_Profile" { + if newState == fsm.ASK_PROFILE { sendProfile(state, data) } } @@ -162,7 +164,7 @@ func storeSecureInternetConfig(state *eduvpn.VPNState, url string, directory str func getSecureInternetAll(homeURL string) { state := &eduvpn.VPNState{} - state.Register("org.eduvpn.app.linux", "configs", func(old string, new string, data string) { + state.Register("org.eduvpn.app.linux", "configs", func(old eduvpn.VPNStateID, new eduvpn.VPNStateID, data string) { stateCallback(state, old, new, data) }, true) @@ -203,7 +205,7 @@ func getSecureInternetAll(homeURL string) { func printConfig(url string, serverType ServerTypes) { state := &eduvpn.VPNState{} - state.Register("org.eduvpn.app.linux", "configs", func(old string, new string, data string) { + state.Register("org.eduvpn.app.linux", "configs", func(old eduvpn.VPNStateID, new eduvpn.VPNStateID, data string) { stateCallback(state, old, new, data) }, true) |
