summaryrefslogtreecommitdiff
path: root/pkg/vpn/bonafide/eip_service.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/vpn/bonafide/eip_service.go')
-rw-r--r--pkg/vpn/bonafide/eip_service.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/pkg/vpn/bonafide/eip_service.go b/pkg/vpn/bonafide/eip_service.go
index ff73da9..49f4bb1 100644
--- a/pkg/vpn/bonafide/eip_service.go
+++ b/pkg/vpn/bonafide/eip_service.go
@@ -214,6 +214,7 @@ func (eip *eipService) sortGatewaysByGeolocation(geolocatedGateways []string) {
}
}
}
+
for _, host := range geolocatedGateways {
for _, gw := range eip.Gateways {
if gw.Host == host {
@@ -221,7 +222,17 @@ func (eip *eipService) sortGatewaysByGeolocation(geolocatedGateways []string) {
}
}
}
- eip.Gateways = gws
+
+ if len(gws) == 0 {
+ log.Println("ERROR: avoiding to replace eip.Gateways will null list. Is the geolocation service properly configured?")
+ } else {
+ if len(gws) > 2 {
+ eip.Gateways = gws[:3]
+ } else {
+ eip.Gateways = gws
+ }
+ log.Println("Picked best gateways for location:", eip.Gateways)
+ }
}
type gatewayDistance struct {