From 53c3020712351eb3f7c3ee3346b60d0c0dc0d0c5 Mon Sep 17 00:00:00 2001 From: Pea Nut <peanut2@systemli.org> Date: Mon, 1 Jul 2024 11:48:48 +0200 Subject: [PATCH] Don't return gateway twice if location is selected manually, fixes #823 This fixes a small logic error. Each gateway can be multiple times in p.recommened (for each transport). If a location was selected manually, each gateway was added twice to the returned list. The returned list is the list of gateways we will connect to. For more information, please check: https://0xacab.org/leap/bitmask-vpn/-/merge_requests/213 --- pkg/vpn/bonafide/gateways.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/vpn/bonafide/gateways.go b/pkg/vpn/bonafide/gateways.go index 88c7581e..bbf5e084 100644 --- a/pkg/vpn/bonafide/gateways.go +++ b/pkg/vpn/bonafide/gateways.go @@ -173,10 +173,10 @@ func (p *gatewayPool) getGatewaysFromMenshenByLocation(location, transport strin var gateways []Gateway for _, gw := range p.recommended { + if !gw.gateway.isTransport(transport) { + continue + } for _, locatedGw := range gws { - if !locatedGw.isTransport(transport) { - continue - } if locatedGw.Host == gw.gateway.Host { gateways = append(gateways, *locatedGw) break -- GitLab