summaryrefslogtreecommitdiff
path: root/state.go
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2022-05-09 14:15:59 +0200
committerjwijenbergh <jeroenwijenbergh@protonmail.com>2022-05-09 14:15:59 +0200
commitfd0753c5463b4c54d09712336301e174f05e05ab (patch)
tree04a4d431768ddb5b44041f8bde924037351892ee /state.go
parentcf09eeab98736e4e52e8909eb0ae85785751dc53 (diff)
State: Implement SetDisconnected/SetConnected
Diffstat (limited to 'state.go')
-rw-r--r--state.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/state.go b/state.go
index 47f23df..14b8eb6 100644
--- a/state.go
+++ b/state.go
@@ -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