mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
Represent NATTypeMeasurementInterval in time.Duration
Adopted the change in according to the recommendation from https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/-/merge_requests/62#note_2761566
This commit is contained in:
parent
c49f72eb0c
commit
0c62d806a4
2 changed files with 6 additions and 6 deletions
|
@ -112,8 +112,8 @@ type SnowflakeProxy struct {
|
||||||
RelayURL string
|
RelayURL string
|
||||||
// NATProbeURL is the URL of the probe service we use for NAT checks
|
// NATProbeURL is the URL of the probe service we use for NAT checks
|
||||||
NATProbeURL string
|
NATProbeURL string
|
||||||
// NATTypeMeasurementIntervalSecond is time in second before NAT type is retested
|
// NATTypeMeasurementInterval is time before NAT type is retested
|
||||||
NATTypeMeasurementIntervalSecond uint
|
NATTypeMeasurementInterval time.Duration
|
||||||
shutdown chan struct{}
|
shutdown chan struct{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -550,14 +550,14 @@ func (sf *SnowflakeProxy) Start() error {
|
||||||
log.Printf("NAT type: %s", currentNATTypeLoaded)
|
log.Printf("NAT type: %s", currentNATTypeLoaded)
|
||||||
|
|
||||||
NatRetestTask := task.Periodic{
|
NatRetestTask := task.Periodic{
|
||||||
Interval: time.Second * time.Duration(sf.NATTypeMeasurementIntervalSecond),
|
Interval: sf.NATTypeMeasurementInterval,
|
||||||
Execute: func() error {
|
Execute: func() error {
|
||||||
sf.checkNATType(config, sf.NATProbeURL)
|
sf.checkNATType(config, sf.NATProbeURL)
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if sf.NATTypeMeasurementIntervalSecond != 0 {
|
if sf.NATTypeMeasurementInterval != 0 {
|
||||||
NatRetestTask.Start()
|
NatRetestTask.Start()
|
||||||
defer NatRetestTask.Close()
|
defer NatRetestTask.Close()
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ func main() {
|
||||||
KeepLocalAddresses: *keepLocalAddresses,
|
KeepLocalAddresses: *keepLocalAddresses,
|
||||||
RelayURL: *relayURL,
|
RelayURL: *relayURL,
|
||||||
|
|
||||||
NATTypeMeasurementIntervalSecond: uint(NATTypeMeasurementInterval.Seconds()),
|
NATTypeMeasurementInterval: *NATTypeMeasurementInterval,
|
||||||
}
|
}
|
||||||
|
|
||||||
var logOutput io.Writer = os.Stderr
|
var logOutput io.Writer = os.Stderr
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue