diff --git a/main.go b/main.go index 5c114e54982fce03f3e26f1e6f5194620b63c8fe..cddc8bddf8e1e684fdd0f846ed5fb82c2f53a834 100644 --- a/main.go +++ b/main.go @@ -120,6 +120,7 @@ func main() { var cacheFile string var templatesDir string var torBinary string + var testTimeout int flag.StringVar(&addr, "addr", ":5000", "Address to listen on.") flag.BoolVar(&web, "web", false, "Enable the web interface (in addition to the JSON API).") @@ -131,6 +132,7 @@ func main() { flag.StringVar(&cacheFile, "cache", "bridgestrap-cache.bin", "Cache file that contains test results.") flag.StringVar(&templatesDir, "templates", "templates", "Path to directory that contains our web templates.") flag.StringVar(&torBinary, "tor", "tor", "Path to tor executable.") + flag.IntVar(&testTimeout, "timeout", 60, "Test timeout in seconds.") flag.Parse() if showVersion { @@ -165,6 +167,8 @@ func main() { return } + TorTestTimeout = time.Duration(testTimeout) * time.Second + log.Printf("Setting Tor test timeout to %s.", TorTestTimeout) torCtx = &TorContext{TorBinary: torBinary} if err = torCtx.Start(); err != nil { log.Printf("Failed to start Tor process: %s", err) diff --git a/tor.go b/tor.go index 301d0107ae4de6e99a9b9c997982cdfaa0a59116..1a69b7bc2fd3bfdc4daad1f500febc929e7177a6 100644 --- a/tor.go +++ b/tor.go @@ -23,12 +23,13 @@ const ( DefaultBridge1 = "obfs4 192.95.36.142:443 CDF2E852BF539B82BD10E27E9115A31734E378C2 cert=qUVQ0srL1JI/vO6V6m/24anYXiJD3QP2HgzUKQtQ7GRqqUvs7P+tG43RtAqdhLOALP7DJQ iat-mode=1" DefaultBridge2 = "obfs4 193.11.166.194:27015 2D82C2E354D531A68469ADF7F878FA6060C6BACA cert=4TLQPJrTSaDffMK7Nbao6LC7G9OW/NHkUwIdjLSS3KYf0Nv4/nQiiI8dY2TcsQx01NniOg iat-mode=0" DefaultBridge3 = "obfs4 37.218.245.14:38224 D9A82D2F9C2F65A18407B1D2B764F130847F8B5D cert=bjRaMrr1BRiAW8IE9U5z27fQaYgOhX1UCmOpg2pFpoMvo6ZgQMzLsaTzzQNTlm7hNcb+Sg iat-mode=0" - // The amount of time we give Tor to test a batch of bridges. - TorTestTimeout = time.Minute // The maximum amount of bridges per batch. MaxBridgesPerReq = 100 ) +// The amount of time we give Tor to test a batch of bridges. +var TorTestTimeout time.Duration + // getBridgeIdentifier turns the given bridgeLine into a canonical identifier // that we use to look for relevant ORCONN events. If the given bridge line // contains a fingerprint, the function returns $FINGERPRINT. If it doesn't,