summaryrefslogtreecommitdiff
path: root/internal/server
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2022-12-20 15:35:44 +0100
committerjwijenbergh <jeroenwijenbergh@protonmail.com>2022-12-21 18:28:00 +0100
commit6981666c6d8f639a1ff9c09a3bc08769e19928af (patch)
treebdb94d76a7fb6a08ef200e9bbbbd5fff1d6b134c /internal/server
parent697dfed1f9f5d2916889a81a7a64bd1158caf2d2 (diff)
Failover: Initial implementation
Diffstat (limited to 'internal/server')
-rw-r--r--internal/server/base.go2
-rw-r--r--internal/server/profile.go4
-rw-r--r--internal/server/server.go8
3 files changed, 8 insertions, 6 deletions
diff --git a/internal/server/base.go b/internal/server/base.go
index 6eb305b..dd15aff 100644
--- a/internal/server/base.go
+++ b/internal/server/base.go
@@ -30,7 +30,7 @@ func (b *Base) ValidProfiles(wireguardSupport bool) ProfileInfo {
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 {
+ if !p.SupportsOpenVPN() && !wireguardSupport {
continue
}
valid = append(valid, p)
diff --git a/internal/server/profile.go b/internal/server/profile.go
index 97781e4..d981421 100644
--- a/internal/server/profile.go
+++ b/internal/server/profile.go
@@ -35,10 +35,10 @@ func (profile *Profile) supportsProtocol(protocol string) bool {
return false
}
-func (profile *Profile) supportsWireguard() bool {
+func (profile *Profile) SupportsWireguard() bool {
return profile.supportsProtocol("wireguard")
}
-func (profile *Profile) supportsOpenVPN() bool {
+func (profile *Profile) SupportsOpenVPN() bool {
return profile.supportsProtocol("openvpn")
}
diff --git a/internal/server/server.go b/internal/server/server.go
index 9354883..78f6472 100644
--- a/internal/server/server.go
+++ b/internal/server/server.go
@@ -1,6 +1,7 @@
package server
import (
+ "os"
"time"
"github.com/eduvpn/eduvpn-common/internal/oauth"
@@ -219,7 +220,7 @@ func HasValidProfile(srv Server, wireguardSupport bool) (bool, error) {
return false, err
}
// Profile does not support OpenVPN but the client also doesn't support WireGuard
- if !p.supportsOpenVPN() && !wireguardSupport {
+ if !p.SupportsOpenVPN() && !wireguardSupport {
return false, nil
}
return true, nil
@@ -242,8 +243,9 @@ func Config(server Server, wireguardSupport bool, preferTCP bool) (string, strin
return "", "", err
}
- ovpn := p.supportsOpenVPN()
- wg := p.supportsWireguard() && wireguardSupport
+ ovpn := p.SupportsOpenVPN()
+ wg := p.SupportsWireguard() && wireguardSupport
+
// If we don't prefer TCP and this profile and client supports wireguard,
// we disable openvpn if the EDUVPN_PREFER_WG environment variable is set
// This is useful to force WireGuard if the profile supports both OpenVPN and WireGuard but the server still prefers OpenVPN