commit 8bc32f580791c80a671cdb0a22ff56bbb4f244fb Author: Cecylia Bocovich cohosh@torproject.org Date: Thu Jan 21 10:20:50 2021 -0500
Set NAT type to restricted after 3 failed connects
Only set the NAT type to restricted after we fail to connect to a restricted client 3 times in a row. --- snowflake.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/snowflake.js b/snowflake.js index 1937fdb..091e046 100644 --- a/snowflake.js +++ b/snowflake.js @@ -23,6 +23,7 @@ class Snowflake { this.broker = broker; this.broker.setNATType(ui.natType); this.proxyPairs = []; + this.natFailures = 0; this.pollInterval = this.config.defaultBrokerPollInterval; if (void 0 === this.config.rateLimitBytes) { this.rateLimit = new DummyRateLimit(); @@ -82,10 +83,12 @@ class Snowflake { this.pollInterval = Math.min(this.pollInterval + this.config.pollAdjustment, this.config.slowestBrokerPollInterval); - // if we fail to connect to a restricted client, assume restricted NAT - if (clientNAT == "restricted"){ + // if we fail to connect to a restricted client 3 times in + // a row, assume we have a restricted NAT + if ((clientNAT == "restricted") && (this.natFailures > 3)){ this.ui.natType = "restricted"; console.log("Learned NAT type: restricted"); + this.natFailures = 0; } this.broker.setNATType(this.ui.natType); } else { @@ -93,6 +96,7 @@ class Snowflake { this.pollInterval = Math.max(this.pollInterval - this.config.pollAdjustment, this.config.defaultBrokerPollInterval); + this.natFailures = 0; } return; }), this.config.datachannelTimeout);
tor-commits@lists.torproject.org