summaryrefslogtreecommitdiff
path: root/internal/server/server.go
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2024-03-14 12:21:20 +0100
committerjwijenbergh <jeroenwijenbergh@protonmail.com>2024-03-14 16:04:20 +0100
commitb98fbee125dd15bbd083de62f7b636ccd0e0248e (patch)
tree9ae45596806e0f4e6a16d78c9675e936b5fc278e /internal/server/server.go
parentc1c2011ec83553a2de7661f89383be4b29883db6 (diff)
All: Make WireGuard support mandatory
Diffstat (limited to 'internal/server/server.go')
-rw-r--r--internal/server/server.go28
1 files changed, 8 insertions, 20 deletions
diff --git a/internal/server/server.go b/internal/server/server.go
index 97a25b4..1182f15 100644
--- a/internal/server/server.go
+++ b/internal/server/server.go
@@ -72,30 +72,20 @@ func (s *Server) api() (*api.API, error) {
return s.apiw, nil
}
-func (s *Server) findProfile(ctx context.Context, wgSupport bool) (*profiles.Profile, error) {
+func (s *Server) findProfile(ctx context.Context) (*profiles.Profile, error) {
// Get the profiles by ignoring the cache
prfs, err := s.FreshProfiles(ctx)
if err != nil {
return nil, err
}
- // No profiles available
- if prfs.Len() == 0 {
- return nil, errors.New("the server has no available profiles for your account")
- }
-
- // No WireGuard support, we have to filter the profiles that only have WireGuard
- if !wgSupport {
- prfs = prfs.FilterWireGuard()
- }
-
var chosenP profiles.Profile
n := prfs.Len()
switch n {
// If we now get no profiles then that means a profile with only WireGuard was removed
case 0:
- return nil, errors.New("the server has only WireGuard profiles but the client does not support WireGuard")
+ return nil, errors.New("the server has no available profiles for your account")
case 1:
// Only one profile, make sure it is set
chosenP = prfs.MustIndex(0)
@@ -114,14 +104,14 @@ func (s *Server) findProfile(ctx context.Context, wgSupport bool) (*profiles.Pro
return &chosenP, nil
}
-func (s *Server) connect(ctx context.Context, wgSupport bool, pTCP bool) (*srvtypes.Configuration, error) {
+func (s *Server) connect(ctx context.Context, pTCP bool) (*srvtypes.Configuration, error) {
a, err := s.api()
if err != nil {
return nil, err
}
// find a suitable profile to connect
- chosenP, err := s.findProfile(ctx, wgSupport)
+ chosenP, err := s.findProfile(ctx)
if err != nil {
return nil, err
}
@@ -130,13 +120,11 @@ func (s *Server) connect(ctx context.Context, wgSupport bool, pTCP bool) (*srvty
return nil, err
}
- protos := []protocol.Protocol{protocol.OpenVPN}
- if wgSupport {
- protos = append(protos, protocol.WireGuard)
- }
- // If the client supports WireGuard and the profile supports both protocols we remove openvpn from client support if EDUVPN_PREFER_WG is set to "1"
+ // protos supported by the client
+ protos := []protocol.Protocol{protocol.OpenVPN, protocol.WireGuard}
+ // If profile supports both protocols we remove openvpn from client support if EDUVPN_PREFER_WG is set to "1"
// This also only happens if prefer TCP is set to false
- if wgSupport && os.Getenv("EDUVPN_PREFER_WG") == "1" {
+ if os.Getenv("EDUVPN_PREFER_WG") == "1" {
if chosenP.HasWireGuard() && chosenP.HasOpenVPN() {
protos = []protocol.Protocol{protocol.WireGuard}
}