From 709220836e10f559a11c2b70177f6d58d9b7a0a1 Mon Sep 17 00:00:00 2001 From: "kali kaneko (leap communications)" Date: Wed, 19 Aug 2020 17:40:36 +0200 Subject: [debug] improve error handling for geolocation --- pkg/vpn/bonafide/eip_service.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'pkg/vpn/bonafide/eip_service.go') 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 { -- cgit v1.2.3