summaryrefslogtreecommitdiff
path: root/internal/server
diff options
context:
space:
mode:
Diffstat (limited to 'internal/server')
-rw-r--r--internal/server/server.go28
-rw-r--r--internal/server/servers.go9
2 files changed, 11 insertions, 26 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}
}
diff --git a/internal/server/servers.go b/internal/server/servers.go
index 64e64b6..36f9ea7 100644
--- a/internal/server/servers.go
+++ b/internal/server/servers.go
@@ -26,8 +26,6 @@ type Callbacks interface {
type Servers struct {
clientID string
cb Callbacks
- // WGSupport defines whether or not wireguard support is enabled
- WGSupport bool
config *v2.V2
}
@@ -37,11 +35,10 @@ func (s *Servers) Remove(identifier string, t srvtypes.Type) error {
}
// NewServers creates a new servers struct
-func NewServers(name string, cb Callbacks, wgSupport bool, cfg *v2.V2) Servers {
+func NewServers(name string, cb Callbacks, cfg *v2.V2) Servers {
return Servers{
clientID: name,
cb: cb,
- WGSupport: wgSupport,
config: cfg,
}
}
@@ -107,7 +104,7 @@ func (s *Servers) ConnectWithCallbacks(ctx context.Context, srv *Server, pTCP bo
if err != nil {
return nil, err
}
- cfg, err := srv.connect(ctx, s.WGSupport, pTCP)
+ cfg, err := srv.connect(ctx, pTCP)
if err == nil {
return cfg, nil
}
@@ -127,5 +124,5 @@ func (s *Servers) ConnectWithCallbacks(ctx context.Context, srv *Server, pTCP bo
if err != nil {
return nil, err
}
- return srv.connect(ctx, s.WGSupport, pTCP)
+ return srv.connect(ctx, pTCP)
}