blob: 42f0e52fa990425d5e6d1958f69d83c2c0c36517 (
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
38
39
40
41
42
43
44
45
46
|
package server
type Profile struct {
ID string `json:"profile_id"`
DisplayName string `json:"display_name"`
VPNProtoList []string `json:"vpn_proto_list"`
DefaultGateway bool `json:"default_gateway"`
}
type ProfileListInfo struct {
ProfileList []Profile `json:"profile_list"`
}
type ProfileInfo struct {
Current string `json:"current_profile"`
Info ProfileListInfo `json:"info"`
}
func (info ProfileInfo) GetCurrentProfileIndex() int {
index := 0
for _, profile := range info.Info.ProfileList {
if profile.ID == info.Current {
return index
}
index++
}
// Default is 'first' profile
return 0
}
func (profile *Profile) supportsProtocol(protocol string) bool {
for _, proto := range profile.VPNProtoList {
if proto == protocol {
return true
}
}
return false
}
func (profile *Profile) supportsWireguard() bool {
return profile.supportsProtocol("wireguard")
}
func (profile *Profile) supportsOpenVPN() bool {
return profile.supportsProtocol("openvpn")
}
|