Periodic NAT Type Measurement Support (Fix #40075)
This pull request adds periodic NAT Type measurement support to snowflake. The default behaviour is unmodified. To enable this periodic NAT Type measurement set nat-type-measurement-interval-second
to a non-zero value.
Things to look at:
- Copyright. This pull request includes ported infrastructure codes from V2Ray for managed periodic tasks. If reusing MIT code is not allowed, this code needs to be rewritten.
- No exhaustive test. The network environment cannot be easily modified. Lookup Table is not tested.
- Flag name too long. There should be a shorter name for
nat-type-measurement-interval-second
that contains the same or more information. - Change of default behaviour. If necessary, flag
nat-type-measurement-interval-second
can have a default value of 86400 to recheck every day by default.
Merge request reports
Activity
- Resolved by meskio
18 18 unsafeLogging := flag.Bool("unsafe-logging", false, "prevent logs from being scrubbed") 19 19 keepLocalAddresses := flag.Bool("keep-local-addresses", false, "keep local LAN address ICE candidates") 20 20 relayURL := flag.String("relay", sf.DefaultRelayURL, "websocket relay URL") 21 NATTypeMeasurementIntervalSecond := flag.Uint("nat-type-measurement-interval-second", 0, 22 "the time interval in second before NAT type is retested, 0 disables retest") The default probe interval is set to 86400 in !62 (1b79962c).
changed this line in version 7 of the diff
18 18 unsafeLogging := flag.Bool("unsafe-logging", false, "prevent logs from being scrubbed") 19 19 keepLocalAddresses := flag.Bool("keep-local-addresses", false, "keep local LAN address ICE candidates") 20 20 relayURL := flag.String("relay", sf.DefaultRelayURL, "websocket relay URL") 21 NATTypeMeasurementIntervalSecond := flag.Uint("nat-type-measurement-interval-second", 0, 22 "the time interval in second before NAT type is retested, 0 disables retest") nat-type-measurement-interval-second
is a bit long, can we come up with something sorter?nat-measure-seconds
?check-nat-seconds
? ...Edited by meskioHow about using
time.ParseDuration
, instead of always using a unit of seconds? The argument could be something like24h
,3h
,3600s
, etc.Personally, I think
time.ParseDuration
is a great choice. The only issue used to be the users cannot guess the format of input based on the flag name. Now that the user cannot reliably guess the meaning of the flag after the flag is renamed, and have to consult the document anyway, this change has no adverse effects at all.I will update the code to reflect this change.
changed this line in version 7 of the diff
I don't know if it's better, but there is also
flag.Duration
which would avoid a separatetime.ParseDuration
step. (But the error message for a syntax error may not be customizable in this case.)I have adopted this recommendation in c49f72eb. I don't think there will be a need to customize it in the near future while this change makes the code more idiomatic.
- Resolved by meskio
- Resolved by meskio
- Resolved by meskio
mentioned in commit shelikhoo/snowflake@67506ed0
mentioned in commit shelikhoo/snowflake@102d410b
mentioned in commit shelikhoo/snowflake@4159f44a
mentioned in commit shelikhoo/snowflake@2547883c
mentioned in commit shelikhoo/snowflake@59af9927
mentioned in commit shelikhoo/snowflake@1b79962c
added 9 commits
-
4159f44a...ead5a960 - 2 commits from branch
tpo/anti-censorship/pluggable-transports:main
- 04bc471a - Support recurring NAT Type measurement
- 4c8a1661 - Port V2Ray periodic task standard library to snowflake
- ac97ce71 - Add NAT Type measurement command line flag
- a6a53ff8 - Add NAT Type test periodic task
- 2547883c - Extract function getCurrentNATType()
- 59af9927 - Refactor state transfer logic to simplify it
- 1b79962c - Rename flag to nat-retest-seconds and retest daily by default
Toggle commit list-
4159f44a...ead5a960 - 2 commits from branch
mentioned in commit shelikhoo/snowflake@d4fdb35e