summaryrefslogtreecommitdiff
path: root/internal/api/profiles
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2024-02-07 13:45:10 +0100
committerJeroen Wijenbergh <46386452+jwijenbergh@users.noreply.github.com>2024-02-19 14:15:07 +0100
commitfe5f8c80298e46a6940e3ad087f559942edb4a06 (patch)
tree77d906f0bc47bbf83c7a06fe4386554ced21fecd /internal/api/profiles
parent09a04c49709bc2e2429c1bfbd44ca34e22e22113 (diff)
API + Server: Support vpn_proto_transport_list
Diffstat (limited to 'internal/api/profiles')
-rw-r--r--internal/api/profiles/profiles.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/internal/api/profiles/profiles.go b/internal/api/profiles/profiles.go
index 2f4fed7..7b9dafc 100644
--- a/internal/api/profiles/profiles.go
+++ b/internal/api/profiles/profiles.go
@@ -9,6 +9,7 @@ type Profile struct {
ID string `json:"profile_id"`
DisplayName string `json:"display_name"`
VPNProtoList []string `json:"vpn_proto_list"`
+ VPNProtoTransportList []string `json:"vpn_proto_transport_list"`
DefaultGateway bool `json:"default_gateway"`
DNSSearchDomains []string `json:"dns_search_domain_list"`
}
@@ -47,6 +48,23 @@ func hasProtocol(protos []string, proto protocol.Protocol) bool {
return false
}
+func (p *Profile) ShouldFailover() bool {
+ // old servers don't support it, only failover in case OpenVPN is supported
+ if len(p.VPNProtoTransportList) == 0 {
+ // this checks VPNProtoList
+ return p.HasOpenVPN()
+ }
+ for _, c := range p.VPNProtoTransportList {
+ if c == "wireguard+tcp" {
+ return true
+ }
+ if c == "openvpn+tcp" {
+ return true
+ }
+ }
+ return false
+}
+
func (p *Profile) HasOpenVPN() bool {
return hasProtocol(p.VPNProtoList, protocol.OpenVPN)
}