summaryrefslogtreecommitdiff
path: root/internal/api/profiles/profiles.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/api/profiles/profiles.go')
-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)
}