commit 0c62d806a4352c054f80bb0f604eb7de7f1430e0 Author: Shelikhoo xiaokangwang@outlook.com Date: Tue Nov 16 19:25:27 2021 +0000
Represent NATTypeMeasurementInterval in time.Duration
Adopted the change in according to the recommendation from
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowf... --- proxy/lib/snowflake.go | 10 +++++----- proxy/main.go | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/proxy/lib/snowflake.go b/proxy/lib/snowflake.go index df6a256..a9ac399 100644 --- a/proxy/lib/snowflake.go +++ b/proxy/lib/snowflake.go @@ -112,9 +112,9 @@ type SnowflakeProxy struct { RelayURL string // NATProbeURL is the URL of the probe service we use for NAT checks NATProbeURL string - // NATTypeMeasurementIntervalSecond is time in second before NAT type is retested - NATTypeMeasurementIntervalSecond uint - shutdown chan struct{} + // NATTypeMeasurementInterval is time before NAT type is retested + NATTypeMeasurementInterval time.Duration + shutdown chan struct{} }
// Checks whether an IP address is a remote address for the client @@ -550,14 +550,14 @@ func (sf *SnowflakeProxy) Start() error { log.Printf("NAT type: %s", currentNATTypeLoaded)
NatRetestTask := task.Periodic{ - Interval: time.Second * time.Duration(sf.NATTypeMeasurementIntervalSecond), + Interval: sf.NATTypeMeasurementInterval, Execute: func() error { sf.checkNATType(config, sf.NATProbeURL) return nil }, }
- if sf.NATTypeMeasurementIntervalSecond != 0 { + if sf.NATTypeMeasurementInterval != 0 { NatRetestTask.Start() defer NatRetestTask.Close() } diff --git a/proxy/main.go b/proxy/main.go index de33d42..b85dde0 100644 --- a/proxy/main.go +++ b/proxy/main.go @@ -31,7 +31,7 @@ func main() { KeepLocalAddresses: *keepLocalAddresses, RelayURL: *relayURL,
- NATTypeMeasurementIntervalSecond: uint(NATTypeMeasurementInterval.Seconds()), + NATTypeMeasurementInterval: *NATTypeMeasurementInterval, }
var logOutput io.Writer = os.Stderr
tor-commits@lists.torproject.org