diff options
author | Ruben Pollan <meskio@sindominio.net> | 2021-03-23 17:10:45 +0100 |
---|---|---|
committer | kali kaneko (leap communications) <kali@leap.se> | 2021-05-04 14:58:39 +0200 |
commit | b14d048e6089233f5c698426652e85bfa1d89488 (patch) | |
tree | b1542d03377740f7335c9848a751ad16426632f0 /pkg/vpn | |
parent | 8c4edf29112a32f267d19717637bf2104c28b969 (diff) |
Don't expose the full gateway out of the vpn module
We just care about locations and fullness.
Diffstat (limited to 'pkg/vpn')
-rw-r--r-- | pkg/vpn/bonafide/bonafide.go | 9 | ||||
-rw-r--r-- | pkg/vpn/bonafide/gateways.go | 10 | ||||
-rw-r--r-- | pkg/vpn/openvpn.go | 14 |
3 files changed, 9 insertions, 24 deletions
diff --git a/pkg/vpn/bonafide/bonafide.go b/pkg/vpn/bonafide/bonafide.go index 321b47f..e0d9c9c 100644 --- a/pkg/vpn/bonafide/bonafide.go +++ b/pkg/vpn/bonafide/bonafide.go @@ -224,13 +224,8 @@ func (b *Bonafide) GetAllGateways(transport string) ([]Gateway, error) { return gws, err } -func (b *Bonafide) PickGatewayForCities(transport string) (map[string]Gateway, error) { - return b.gateways.pickGatewayForCities(transport), nil -} - -func (b *Bonafide) GetGatewayDetails(host string) (Gateway, error) { - gw, err := b.gateways.getGatewayByHost(host) - return gw, err +func (b *Bonafide) ListLocationFullness(transport string) map[string]float64 { + return b.gateways.listLocationFullness(transport) } func (b *Bonafide) SetManualGateway(label string) { diff --git a/pkg/vpn/bonafide/gateways.go b/pkg/vpn/bonafide/gateways.go index 2d94c63..5474a2f 100644 --- a/pkg/vpn/bonafide/gateways.go +++ b/pkg/vpn/bonafide/gateways.go @@ -34,7 +34,7 @@ type Gateway struct { Protocols []string Options map[string]string Transport string - Fullness float32 + Fullness float64 } /* gatewayDistance is used in the timezone distance fallback */ @@ -96,13 +96,13 @@ func (p *gatewayPool) isValidCity(city string) bool { return valid } -/* returns a map of city: gateway for the ui to use */ -func (p *gatewayPool) pickGatewayForCities(transport string) map[string]Gateway { +/* returns a map of location: fullness for the ui to use */ +func (p *gatewayPool) listLocationFullness(transport string) map[string]float64 { cities := p.getCities() - cm := make(map[string]Gateway) + cm := make(map[string]float64) for _, city := range cities { gw, _ := p.getRandomGatewayByCity(city, transport) - cm[city] = gw + cm[city] = gw.Fullness } return cm } diff --git a/pkg/vpn/openvpn.go b/pkg/vpn/openvpn.go index 298ea75..1447458 100644 --- a/pkg/vpn/openvpn.go +++ b/pkg/vpn/openvpn.go @@ -25,7 +25,6 @@ import ( "strconv" "strings" - "0xacab.org/leap/bitmask-vpn/pkg/vpn/bonafide" "0xacab.org/leap/shapeshifter" ) @@ -231,17 +230,8 @@ func (b *Bitmask) VPNCheck() (helpers bool, privilege bool, err error) { return b.launch.check() } -func (b *Bitmask) ListGatewaysByCity(transport string) (map[string]bonafide.Gateway, error) { - gwForCities, err := b.bonafide.PickGatewayForCities(transport) - return gwForCities, err -} - -func (b *Bitmask) GetGatewayDetails(host string) (interface{}, error) { - gw, err := b.bonafide.GetGatewayDetails(host) - if err != nil { - return bonafide.Gateway{}, err - } - return gw, nil +func (b *Bitmask) ListLocationFullness(transport string) map[string]float64 { + return b.bonafide.ListLocationFullness(transport) } // UseGateway selects a gateway, by label, as the default gateway |