diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-05-09 14:15:59 +0200 |
|---|---|---|
| committer | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-05-09 14:15:59 +0200 |
| commit | fd0753c5463b4c54d09712336301e174f05e05ab (patch) | |
| tree | 04a4d431768ddb5b44041f8bde924037351892ee /state.go | |
| parent | cf09eeab98736e4e52e8909eb0ae85785751dc53 (diff) | |
State: Implement SetDisconnected/SetConnected
Diffstat (limited to 'state.go')
| -rw-r--r-- | state.go | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -180,6 +180,24 @@ func (state *VPNState) SetProfileID(profileID string) error { return nil } +func (state *VPNState) SetConnected() error { + if !state.FSM.HasTransition(internal.CONNECTED) { + return &internal.FSMWrongStateTransitionError{Got: state.FSM.Current, Want: internal.CONNECTED} + } + + state.FSM.GoTransition(internal.CONNECTED) + return nil +} + +func (state *VPNState) SetDisconnected() error { + if !state.FSM.HasTransition(internal.HAS_CONFIG) { + return &internal.FSMWrongStateTransitionError{Got: state.FSM.Current, Want: internal.HAS_CONFIG} + } + + state.FSM.GoTransition(internal.HAS_CONFIG) + return nil +} + type StateSetProfileError struct { ProfileID string Err error |
