summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJeroen Wijenbergh <jeroenwijenbergh@protonmail.com>2022-03-07 17:34:39 +0100
committerjwijenbergh <jeroenwijenbergh@protonmail.com>2022-04-05 12:26:13 +0200
commite2bcbc5d7fc8846ed189863ab33f0514f5399365 (patch)
tree3f20ed0c7f0381bda7535e5baa38fe251e98635b /src
parent56548c511163b4dd22d9a96a2f5ae647f1627a7b (diff)
Begin exporting by wrapping state in a singleton
Diffstat (limited to 'src')
-rw-r--r--src/state.go23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/state.go b/src/state.go
index a03733a..22dcaaf 100644
--- a/src/state.go
+++ b/src/state.go
@@ -12,13 +12,28 @@ type EduVPNState struct {
Server string
}
-func Register(name string, server string) *EduVPNState {
- state := &EduVPNState{Name: name, Server: server}
+func Register(state *EduVPNState, name string, server string) error {
+ state.Name = name
+ state.Server = server
+
endpoints, err := APIGetEndpoints(state)
if err != nil {
- panic(err)
+ return err
}
+
state.Endpoints = endpoints
- return state
+ return nil
}
+
+
+var VPNStateInstance *EduVPNState
+
+func GetVPNState() *EduVPNState {
+ if VPNStateInstance == nil {
+ VPNStateInstance = &EduVPNState{}
+ }
+ return VPNStateInstance
+}
+
+