blob: dd15affd308b3a7bd6d3e1a2677e51a9e4d2d783 (
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
|
package server
import (
"time"
)
// Base is 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 (b *Base) InitializeEndpoints() error {
ep, err := APIGetEndpoints(b.URL)
if err != nil {
return err
}
b.Endpoints = *ep
return nil
}
func (b *Base) ValidProfiles(wireguardSupport bool) ProfileInfo {
var valid []Profile
for _, p := range b.Profiles.Info.ProfileList {
// Not a valid profile because it does not support openvpn
// Also the client does not support wireguard
if !p.SupportsOpenVPN() && !wireguardSupport {
continue
}
valid = append(valid, p)
}
return ProfileInfo{
Current: b.Profiles.Current,
Info: ProfileListInfo{ProfileList: valid},
}
}
|