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 /state.go | |
| parent | c5e85ba79d4d091af9873f1fb0e7415c3b17b9f8 (diff) | |
Refactor: Use constants for state callbacks instead of strings
Diffstat (limited to 'state.go')
| -rw-r--r-- | state.go | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -13,6 +13,8 @@ import ( "github.com/jwijenbergh/eduvpn-common/internal/util" ) +type VPNStateID = fsm.FSMStateID + type VPNState struct { // The chosen server Servers server.Servers `json:"servers"` @@ -43,7 +45,7 @@ func (state *VPNState) GetSavedServers() string { return serversJSON } -func (state *VPNState) Register(name string, directory string, stateCallback func(string, string, string), debug bool) error { +func (state *VPNState) Register(name string, directory string, stateCallback func(VPNStateID, VPNStateID, string), debug bool) error { errorMessage := "failed to register with the GO library" if !state.FSM.InState(fsm.DEREGISTERED) { return &types.WrappedErrorMessage{Message: errorMessage, Err: fsm.DeregisteredError{}.CustomError()} @@ -406,7 +408,7 @@ func (state *VPNState) RenewSession() error { } oauthStructure := currentServer.GetOAuth() - oauthStructure.Token = oauth.OAuthToken{Access: "",Refresh: "",Type: "",Expires: 0,ExpiredTimestamp: util.GetCurrentTime()} + oauthStructure.Token = oauth.OAuthToken{Access: "", Refresh: "", Type: "", Expires: 0, ExpiredTimestamp: util.GetCurrentTime()} // Make sure the FSM is initialized oauthStructure.FSM = &state.FSM @@ -422,7 +424,6 @@ func (state *VPNState) RenewSession() error { return nil } - func (state *VPNState) ShouldRenewButton() bool { if !state.FSM.InState(fsm.CONNECTED) { return false |
