diff options
author | kali kaneko (leap communications) <kali@leap.se> | 2021-11-29 18:09:24 +0100 |
---|---|---|
committer | kali kaneko (leap communications) <kali@leap.se> | 2021-11-29 18:14:20 +0100 |
commit | c7148d9559dab0e1cdbc6dd5306a3c852615560e (patch) | |
tree | f016eb430d971783da1c767a03ca4b48ba28451b /pkg | |
parent | 891780cf652aedca23b050248f43584d4e6ad611 (diff) |
[feat] hook snowflake on bootstrap
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/vpn/bonafide/bonafide.go | 26 | ||||
-rw-r--r-- | pkg/vpn/bonafide/gateways.go | 9 |
2 files changed, 24 insertions, 11 deletions
diff --git a/pkg/vpn/bonafide/bonafide.go b/pkg/vpn/bonafide/bonafide.go index b4e6af0..907bba5 100644 --- a/pkg/vpn/bonafide/bonafide.go +++ b/pkg/vpn/bonafide/bonafide.go @@ -25,10 +25,12 @@ import ( "io/ioutil" "log" "net/http" + "os" "strings" "time" "0xacab.org/leap/bitmask-vpn/pkg/config" + "0xacab.org/leap/bitmask-vpn/pkg/snowflake" ) const ( @@ -234,18 +236,22 @@ func (b *Bonafide) getURLNoDNS(object string) string { } func (b *Bonafide) maybeInitializeEIP() error { - if b.eip == nil { - err := b.fetchEipJSON() - if err != nil { - return err + if os.Getenv("SNOWFLAKE") == "1" { + snowflake.BootstrapWithSnowflakeProxies() + } else { + if b.eip == nil { + err := b.fetchEipJSON() + if err != nil { + return err + } + b.gateways = newGatewayPool(b.eip) } - b.gateways = newGatewayPool(b.eip) - } - // FIXME: let's update the menshen gateways every time we 'maybe initilize EIP' - // in a future we might want to be more clever on when to do that - // (when opening the locations tab in the UI, only on reconnects, ...) - b.fetchGatewaysFromMenshen() + // FIXME: let's update the menshen gateways every time we 'maybe initilize EIP' + // in a future we might want to be more clever on when to do that + // (when opening the locations tab in the UI, only on reconnects, ...) + b.fetchGatewaysFromMenshen() + } return nil } diff --git a/pkg/vpn/bonafide/gateways.go b/pkg/vpn/bonafide/gateways.go index 633493e..c442e72 100644 --- a/pkg/vpn/bonafide/gateways.go +++ b/pkg/vpn/bonafide/gateways.go @@ -306,7 +306,14 @@ func (p *gatewayPool) getBestLocation(transport string, tz int) string { } func (p *gatewayPool) getAll(transport string, tz int) ([]Gateway, error) { - if len(p.recommended) != 0 { + /* + if (&gatewayPool{} == p) { + log.Println("getAll tried to access uninitialized struct") + return []Gateway{}, nil + } + */ + + if p.recommended == nil || len(p.recommended) == 0 { return p.getGatewaysFromMenshen(transport, 999) } return p.getGatewaysByTimezone(transport, tz, 999) |