summaryrefslogtreecommitdiff
path: root/src/state.go
blob: 5d054bb6b34bf587d7546b0e571d8ee0b8f93e96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package eduvpn

type EduVPNState struct {
	// The endpoints
	Endpoints *EduVPNEndpoints

	// Info passed by the client
	Name   string
	Server string

	// OAuth
	OAuthToken   *EduVPNOAuthToken
	OAuthSession *EduVPNOAuthSession
}

func Register(state *EduVPNState, name string, server string) error {
	state.Name = name
	state.Server = server

	endpoints, err := APIGetEndpoints(state)

	if err != nil {
		return err
	}

	state.Endpoints = endpoints
	return nil
}

var VPNStateInstance *EduVPNState

func GetVPNState() *EduVPNState {
	if VPNStateInstance == nil {
		VPNStateInstance = &EduVPNState{}
	}
	return VPNStateInstance
}