summaryrefslogtreecommitdiff
path: root/pkg/vpn/bonafide/gateways.go
diff options
context:
space:
mode:
authorkali kaneko (leap communications) <kali@leap.se>2021-09-06 21:08:14 +0200
committerkali kaneko (leap communications) <kali@leap.se>2021-11-23 21:51:01 +0100
commit8543125fa656ddc2c114072adfc27e4e7c461695 (patch)
tree176f90c03f64c2645932dbaf3d87f2ad22b61489 /pkg/vpn/bonafide/gateways.go
parentb8e0fe3b5003d22043042110e8036f4383602545 (diff)
[ui] transient connecting state
Diffstat (limited to 'pkg/vpn/bonafide/gateways.go')
-rw-r--r--pkg/vpn/bonafide/gateways.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/pkg/vpn/bonafide/gateways.go b/pkg/vpn/bonafide/gateways.go
index 53ab320..4299bb2 100644
--- a/pkg/vpn/bonafide/gateways.go
+++ b/pkg/vpn/bonafide/gateways.go
@@ -113,6 +113,20 @@ func (p *gatewayPool) listLocationFullness(transport string) map[string]float64
return cm
}
+/* returns a map of location: labels for the ui to use */
+func (p *gatewayPool) listLocationLabels(transport string) map[string][]string {
+ cm := make(map[string][]string)
+ locations := p.getLocations()
+ if len(locations) == 0 {
+ return cm
+ }
+ for _, loc := range locations {
+ current := p.locations[loc]
+ cm[loc] = []string{current.Name, current.CountryCode}
+ }
+ return cm
+}
+
/* this method should only be used if we have no usable menshen list. */
func (p *gatewayPool) getRandomGatewaysByLocation(location, transport string) ([]Gateway, error) {
if !p.isValidLocation(location) {
@@ -274,6 +288,19 @@ func (p *gatewayPool) getBest(transport string, tz, max int) ([]Gateway, error)
}
}
+/* returns the location for the first recommended gateway */
+func (p *gatewayPool) getBestLocation(transport string, tz int) string {
+ best, err := p.getBest(transport, tz, 1)
+ if err != nil {
+ return ""
+ }
+ if len(best) != 1 {
+ return ""
+ }
+ return best[0].Location
+
+}
+
func (p *gatewayPool) getAll(transport string, tz int) ([]Gateway, error) {
if len(p.recommended) != 0 {
return p.getGatewaysFromMenshen(transport, 999)