From ed529ab770ae4dc6dd79bbf819f8cf1b2dfb809b Mon Sep 17 00:00:00 2001
From: Ruben Pollan <meskio@sindominio.net>
Date: Sun, 28 Mar 2021 18:43:21 +0200
Subject: [PATCH] Get the list of locations as soon as possible

---
 pkg/backend/init.go          | 1 +
 pkg/vpn/bonafide/bonafide.go | 4 ++++
 2 files changed, 5 insertions(+)

diff --git a/pkg/backend/init.go b/pkg/backend/init.go
index 7d7a5342..f82c5dcb 100644
--- a/pkg/backend/init.go
+++ b/pkg/backend/init.go
@@ -34,6 +34,7 @@ func initializeContext(opts *InitOpts) {
 	go trigger(OnStatusChanged)
 	go checkErrors(errCh)
 	initializeBitmask(errCh, opts)
+	go trigger(OnStatusChanged)
 }
 
 func checkErrors(errCh chan string) {
diff --git a/pkg/vpn/bonafide/bonafide.go b/pkg/vpn/bonafide/bonafide.go
index 4e1db74c..212361f3 100644
--- a/pkg/vpn/bonafide/bonafide.go
+++ b/pkg/vpn/bonafide/bonafide.go
@@ -225,6 +225,10 @@ func (b *Bonafide) GetAllGateways(transport string) ([]Gateway, error) {
 }
 
 func (b *Bonafide) ListLocationFullness(transport string) map[string]float64 {
+	err := b.maybeInitializeEIP()
+	if err != nil {
+		log.Println("Error fetching eip-service.json:", err)
+	}
 	return b.gateways.listLocationFullness(transport)
 }
 
-- 
GitLab