diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2023-04-12 22:52:49 +0200 |
|---|---|---|
| committer | Jeroen Wijenbergh <46386452+jwijenbergh@users.noreply.github.com> | 2023-09-25 09:43:37 +0200 |
| commit | a23c3e61c5d89ef67973891b5b3a176c06e1b174 (patch) | |
| tree | f1eed03b047f8affd3d5123fa5c9e868ac7d8bec /internal/server/profile.go | |
| parent | ee95eb45708e1fa766a63866d26d05d13f23e8c9 (diff) | |
Refactor: Split internal server into multiple packages
- Pass contexts
- Have separate packages for e.g. custom, institute and secure
- internet servers, profiles....
- Return types from the public ./types package with a Public() method
Diffstat (limited to 'internal/server/profile.go')
| -rw-r--r-- | internal/server/profile.go | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/internal/server/profile.go b/internal/server/profile.go deleted file mode 100644 index d981421..0000000 --- a/internal/server/profile.go +++ /dev/null @@ -1,44 +0,0 @@ -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) CurrentProfileIndex() int { - for i, profile := range info.Info.ProfileList { - if profile.ID == info.Current { - return i - } - } - // 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") -} |
