diff options
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/snowflake/bootstrap.go | 13 | ||||
-rw-r--r-- | pkg/vpn/bonafide/bonafide.go | 45 |
2 files changed, 44 insertions, 14 deletions
diff --git a/pkg/snowflake/bootstrap.go b/pkg/snowflake/bootstrap.go index 5e90b0e..7a093af 100644 --- a/pkg/snowflake/bootstrap.go +++ b/pkg/snowflake/bootstrap.go @@ -22,7 +22,7 @@ import ( // [ ] fix snowflake-client binary // [ ] find tor path -const torrc = `UseBridges 1 +const torrcOrig = `UseBridges 1 DataDirectory datadir ClientTransportPlugin snowflake exec /usr/local/bin/snowflake-client -log /tmp/snowflake.log -url https://snowflake-broker.torproject.net.global.prod.fastly.net/ \ @@ -33,6 +33,17 @@ Bridge snowflake 192.0.2.3:1 SocksPort auto` +const torrc = `UseBridges 1 +DataDirectory datadir + +ClientTransportPlugin snowflake exec /usr/local/bin/snowflake-client -log /tmp/snowflake.log -url https://snowflake-broker.azureedge.net/ \ +-front ajax.aspnetcdn.com -ice stun:stun.l.google.com:19302 \ +-max 5 + +Bridge snowflake 192.0.2.3:1 + +SocksPort auto` + type StatusEvent struct { Progress int Tag string diff --git a/pkg/vpn/bonafide/bonafide.go b/pkg/vpn/bonafide/bonafide.go index 129845f..0fa48ed 100644 --- a/pkg/vpn/bonafide/bonafide.go +++ b/pkg/vpn/bonafide/bonafide.go @@ -47,15 +47,16 @@ const ( ) type Bonafide struct { - client httpClient - eip *eipService - tzOffsetHours int - gateways *gatewayPool - maxGateways int - auth authentication - token []byte - SnowflakeCh chan *snowflake.StatusEvent - snowflake bool + client httpClient + eip *eipService + tzOffsetHours int + gateways *gatewayPool + maxGateways int + auth authentication + token []byte + SnowflakeCh chan *snowflake.StatusEvent + snowflakeProgress int + snowflake bool } type openvpnConfig map[string]interface{} @@ -241,14 +242,32 @@ func (b *Bonafide) getURLNoDNS(object string) string { return "" } +func (b *Bonafide) watchSnowflakeProgress(ch chan *snowflake.StatusEvent) { + // We need to keep track of the bootstrap process here, and then we + // pass to the channel that is observed by the backend + log.Println(">>> WATCH SNOWFLAKE") + go func() { + for { + select { + case evt := <-ch: + b.snowflakeProgress = evt.Progress + b.SnowflakeCh <- evt + } + } + + }() +} + func (b *Bonafide) maybeInitializeEIP() error { // FIXME - use config/bitmask flag if os.Getenv("SNOWFLAKE") == "1" { p := strings.ToLower(config.Provider) - // FIXME only if progress != 100 %, then just pick files. - // we probably need another status watcher internally, to keep track - // of whether we need to cancel, or just wait. - snowflake.BootstrapWithSnowflakeProxies(p, getAPIAddr(p), b.SnowflakeCh) + log.Println(b.snowflakeProgress) + if b.snowflakeProgress != 100 { + ch := make(chan *snowflake.StatusEvent, 20) + b.watchSnowflakeProgress(ch) + snowflake.BootstrapWithSnowflakeProxies(p, getAPIAddr(p), ch) + } err := b.parseEipJSONFromFile() if err != nil { return err |