diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2024-02-07 13:45:10 +0100 |
|---|---|---|
| committer | Jeroen Wijenbergh <46386452+jwijenbergh@users.noreply.github.com> | 2024-02-19 14:15:07 +0100 |
| commit | fe5f8c80298e46a6940e3ad087f559942edb4a06 (patch) | |
| tree | 77d906f0bc47bbf83c7a06fe4386554ced21fecd | |
| parent | 09a04c49709bc2e2429c1bfbd44ca34e22e22113 (diff) | |
API + Server: Support vpn_proto_transport_list
| -rw-r--r-- | internal/api/profiles/profiles.go | 18 | ||||
| -rw-r--r-- | internal/server/server.go | 1 | ||||
| -rw-r--r-- | types/server/server.go | 2 |
3 files changed, 21 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) } diff --git a/internal/server/server.go b/internal/server/server.go index 97dafff..1f73791 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -150,6 +150,7 @@ func (s *Server) connect(ctx context.Context, wgSupport bool, pTCP bool) (*srvty Protocol: apicfg.Protocol, DefaultGateway: chosenP.DefaultGateway, DNSSearchDomains: chosenP.DNSSearchDomains, + ShouldFailover: chosenP.ShouldFailover(), Proxy: proxy, }, nil } diff --git a/types/server/server.go b/types/server/server.go index 5a340b1..46bbc26 100644 --- a/types/server/server.go +++ b/types/server/server.go @@ -175,6 +175,8 @@ type Configuration struct { DefaultGateway bool `json:"default_gateway"` // DNSSearchDomains are the list of dns search domains DNSSearchDomains []string `json:"dns_search_domains,omitempty"` + // ShouldFailover returns whether or not the client should attempt to failover + ShouldFailover bool `json:"should_failover"` // Proxy returns information for proxied VPN connections // If this is non-nil a proxy must be started using StartProxyguard Proxy *Proxy `json:"proxy,omitempty"` |
