blob: bb88eb32e0ee01f5f0ecf99f4e6b747a47095af6 (
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
|
package server
import (
"time"
"github.com/eduvpn/eduvpn-common/types"
)
// The base type for servers.
type Base struct {
URL string `json:"base_url"`
DisplayName map[string]string `json:"display_name"`
SupportContact []string `json:"support_contact"`
Endpoints Endpoints `json:"endpoints"`
Profiles ProfileInfo `json:"profiles"`
StartTime time.Time `json:"start_time"`
EndTime time.Time `json:"expire_time"`
Type string `json:"server_type"`
}
func (base *Base) InitializeEndpoints() error {
errorMessage := "failed initializing endpoints"
endpoints, endpointsErr := APIGetEndpoints(base.URL)
if endpointsErr != nil {
return types.NewWrappedError(errorMessage, endpointsErr)
}
base.Endpoints = *endpoints
return nil
}
func (base *Base) ValidProfiles(clientSupportsWireguard bool) ProfileInfo {
var validProfiles []Profile
for _, profile := range base.Profiles.Info.ProfileList {
// Not a valid profile because it does not support openvpn
// Also the client does not support wireguard
if !profile.supportsOpenVPN() && !clientSupportsWireguard {
continue
}
validProfiles = append(validProfiles, profile)
}
return ProfileInfo{
Current: base.Profiles.Current,
Info: ProfileListInfo{ProfileList: validProfiles},
}
}
|