summaryrefslogtreecommitdiff
path: root/pkg/vpn/bonafide/bonafide.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/vpn/bonafide/bonafide.go')
-rw-r--r--pkg/vpn/bonafide/bonafide.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/pkg/vpn/bonafide/bonafide.go b/pkg/vpn/bonafide/bonafide.go
index 22e3051..8b60641 100644
--- a/pkg/vpn/bonafide/bonafide.go
+++ b/pkg/vpn/bonafide/bonafide.go
@@ -197,6 +197,8 @@ func (b *Bonafide) maybeInitializeEIP() error {
return nil
}
+// GetGateways filters by transport, and will return the maximum number defined
+// in bonafide.maxGateways, or the maximum by default (3).
func (b *Bonafide) GetGateways(transport string) ([]Gateway, error) {
err := b.maybeInitializeEIP()
if err != nil {
@@ -211,6 +213,17 @@ func (b *Bonafide) GetGateways(transport string) ([]Gateway, error) {
return gws, err
}
+// GetAllGateways only filters gateways by transport.
+// TODO could pass "any" instead?
+func (b *Bonafide) GetAllGateways(transport string) ([]Gateway, error) {
+ err := b.maybeInitializeEIP()
+ if err != nil {
+ return nil, err
+ }
+ gws, err := b.gateways.getAll(transport, b.tzOffsetHours)
+ return gws, err
+}
+
func (b *Bonafide) SetManualGateway(label string) {
b.gateways.setUserChoice(label)
}
@@ -219,6 +232,10 @@ func (b *Bonafide) SetAutomaticGateway() {
b.gateways.setAutomaticChoice()
}
+func (b *Bonafide) GetGatewayByIP(ip string) (Gateway, error) {
+ return b.gateways.getGatewayByIP(ip)
+}
+
/* TODO this still needs to be called periodically */
func (b *Bonafide) fetchGatewayRanking() error {
/* FIXME in float deployments, geolocation is served on gemyip.domain/json, with a LE certificate, but in riseup is served behind the api certificate.