diff options
Diffstat (limited to 'pkg/vpn/bonafide/gateways.go')
-rw-r--r-- | pkg/vpn/bonafide/gateways.go | 27 |
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) |