summaryrefslogtreecommitdiff
path: root/pkg/vpn/bonafide/eip_service.go
diff options
context:
space:
mode:
authorkali kaneko (leap communications) <kali@leap.se>2020-08-19 17:40:36 +0200
committerkali kaneko (leap communications) <kali@leap.se>2020-08-20 20:27:47 +0200
commit709220836e10f559a11c2b70177f6d58d9b7a0a1 (patch)
tree17edf8c6d0d20e133f5dcb2747ea4dc35533a4ea /pkg/vpn/bonafide/eip_service.go
parentb9cae0b715ce34cfb0b7f85f023c31ef8ddd54d3 (diff)
[debug] improve error handling for geolocation
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 {