commit 9bdb87eaf355e4dacdf5e1b59b8e37e010b166ba Author: Shelikhoo xiaokangwang@outlook.com Date: Tue Nov 16 11:16:54 2021 +0000
Update nat-retest-seconds format to time.ParseDuration form
Adopted the change in according to the recommendation from
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowf... --- proxy/main.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/proxy/main.go b/proxy/main.go index baac52b..b0f6971 100644 --- a/proxy/main.go +++ b/proxy/main.go @@ -5,6 +5,7 @@ import ( "io" "log" "os" + "time"
"git.torproject.org/pluggable-transports/snowflake.git/v2/common/safelog" sf "git.torproject.org/pluggable-transports/snowflake.git/v2/proxy/lib" @@ -18,8 +19,8 @@ func main() { unsafeLogging := flag.Bool("unsafe-logging", false, "prevent logs from being scrubbed") keepLocalAddresses := flag.Bool("keep-local-addresses", false, "keep local LAN address ICE candidates") relayURL := flag.String("relay", sf.DefaultRelayURL, "websocket relay URL") - NATTypeMeasurementIntervalSecond := flag.Uint("nat-retest-seconds", 86400, - "the time interval in second before NAT type is retested, 0 disables retest") + NATTypeMeasurementIntervalString := flag.String("nat-retest-seconds", "24h", + "the time interval in second before NAT type is retested, 0s disables retest. Valid time units are "s", "m", "h". ")
flag.Parse()
@@ -29,8 +30,12 @@ func main() { BrokerURL: *rawBrokerURL, KeepLocalAddresses: *keepLocalAddresses, RelayURL: *relayURL, + }
- NATTypeMeasurementIntervalSecond: *NATTypeMeasurementIntervalSecond, + if NATTypeMeasurementIntervalTime, err := time.ParseDuration(*NATTypeMeasurementIntervalString); err == nil { + proxy.NATTypeMeasurementIntervalSecond = uint(NATTypeMeasurementIntervalTime.Seconds()) + } else { + log.Fatalf("unable to parse nat-retest-seconds: %v", err) }
var logOutput io.Writer = os.Stderr
tor-commits@lists.torproject.org