[tor-commits] [snowflake/main] Add NAT Type measurement command line flag

meskio at torproject.org meskio at torproject.org
Tue Nov 16 19:37:40 UTC 2021


commit ac97ce7136906287a86c6fc2d9cfdc6b7c313166
Author: Shelikhoo <xiaokangwang at outlook.com>
Date:   Thu Nov 4 20:25:50 2021 +0000

    Add NAT Type measurement command line flag
    
    It is important to include unit in flag name to prevent user from making mistake.
---
 proxy/lib/snowflake.go | 4 +++-
 proxy/main.go          | 4 ++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/proxy/lib/snowflake.go b/proxy/lib/snowflake.go
index 7d237de..f979ed0 100644
--- a/proxy/lib/snowflake.go
+++ b/proxy/lib/snowflake.go
@@ -105,7 +105,9 @@ type SnowflakeProxy struct {
 	RelayURL string
 	// NATProbeURL is the URL of the probe service we use for NAT checks
 	NATProbeURL string
-	shutdown    chan struct{}
+	// NATTypeMeasurementIntervalSecond is time in second before NAT type is retested
+	NATTypeMeasurementIntervalSecond uint
+	shutdown                         chan struct{}
 }
 
 // Checks whether an IP address is a remote address for the client
diff --git a/proxy/main.go b/proxy/main.go
index 7dcbcda..a8e56bb 100644
--- a/proxy/main.go
+++ b/proxy/main.go
@@ -18,6 +18,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-type-measurement-interval-second", 0,
+		"the time interval in second before NAT type is retested, 0 disables retest")
 
 	flag.Parse()
 
@@ -27,6 +29,8 @@ func main() {
 		BrokerURL:          *rawBrokerURL,
 		KeepLocalAddresses: *keepLocalAddresses,
 		RelayURL:           *relayURL,
+
+		NATTypeMeasurementIntervalSecond: *NATTypeMeasurementIntervalSecond,
 	}
 
 	var logOutput io.Writer = os.Stderr





More information about the tor-commits mailing list