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@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);