[tor-commits] [pluggable-transports/snowflake-webext] 01/04: refactor: make 'At client capacity' logic clearer

gitolite role git at cupani.torproject.org
Mon Aug 22 16:21:03 UTC 2022


This is an automated email from the git hooks/post-receive script.

meskio pushed a commit to branch main
in repository pluggable-transports/snowflake-webext.

commit 49c56703e1dbd5f5ebc17efe309a780b01202055
Author: WofWca <wofwca at protonmail.com>
AuthorDate: Fri Jul 15 16:06:18 2022 +0300

    refactor: make 'At client capacity' logic clearer
---
 snowflake.js | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/snowflake.js b/snowflake.js
index b55a3bd..8685753 100644
--- a/snowflake.js
+++ b/snowflake.js
@@ -65,11 +65,11 @@ class Snowflake {
    */
   pollBroker() {
     // Poll broker for clients.
-    const pair = this.makeProxyPair();
-    if (!pair) {
+    if (this.proxyPairs.length >= this.config.maxNumClients) {
       log('At client capacity.');
       return;
     }
+    const pair = this.makeProxyPair();
     log('Polling broker..');
     // Do nothing until a new proxyPair is available.
     let msg = 'Polling for client ... ';
@@ -178,12 +178,9 @@ class Snowflake {
   }
 
   /**
-   * @returns {null | ProxyPair}
+   * @returns {ProxyPair}
    */
   makeProxyPair() {
-    if (this.proxyPairs.length >= this.config.maxNumClients) {
-      return null;
-    }
     const pair = new ProxyPair(this.relayAddr, this.rateLimit, this.config);
     this.proxyPairs.push(pair);
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the tor-commits mailing list