[tor-commits] [flashproxy/master] use CONNECTIONS_PER_CLIENT and MAX_NUM_CLIENTS instead of a single MAX_NUM_PROXY_PAIRS

infinity0 at torproject.org infinity0 at torproject.org
Fri Mar 7 14:39:18 UTC 2014


commit 281c277c5e0c08a40583d3aca1f321e834e0ef34
Author: Ximin Luo <infinity0 at torproject.org>
Date:   Fri Mar 7 13:51:54 2014 +0000

    use CONNECTIONS_PER_CLIENT and MAX_NUM_CLIENTS instead of a single MAX_NUM_PROXY_PAIRS
    - the previous behaviour was misleading, max_clients was effectively half what the user specified
---
 proxy/flashproxy.js |   23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/proxy/flashproxy.js b/proxy/flashproxy.js
index 5367dc6..12c4c1e 100644
--- a/proxy/flashproxy.js
+++ b/proxy/flashproxy.js
@@ -20,7 +20,7 @@
  *
  * max_clients=<NUM>
  * How many clients to serve concurrently. The default is
- * DEFAULT_MAX_NUM_PROXY_PAIRS.
+ * DEFAULT_MAX_NUM_CLIENTS.
  *
  * ratelimit=<FLOAT>(<UNIT>)?|off
  * What rate to limit all proxy traffic combined to. The special value "off"
@@ -64,7 +64,11 @@
 
 var DEFAULT_FACILITATOR_URL = DEFAULT_FACILITATOR_URL || "https://fp-facilitator.org/";
 
-var DEFAULT_MAX_NUM_PROXY_PAIRS = DEFAULT_MAX_NUM_PROXY_PAIRS || 10;
+/* Start two connections because some versions of Tor make two PT connections:
+https://lists.torproject.org/pipermail/tor-dev/2012-December/004221.html
+https://trac.torproject.org/projects/tor/ticket/7733 */
+var CONNECTIONS_PER_CLIENT = 2
+var DEFAULT_MAX_NUM_CLIENTS = DEFAULT_MAX_NUM_CLIENTS || 10;
 
 var DEFAULT_INITIAL_FACILITATOR_POLL_INTERVAL = DEFAULT_INITIAL_FACILITATOR_POLL_INTERVAL || 60.0;
 var DEFAULT_FACILITATOR_POLL_INTERVAL = DEFAULT_FACILITATOR_POLL_INTERVAL || 3600.0;
@@ -493,8 +497,8 @@ function FlashProxy() {
 
         this.fac_url = get_param_string(query, "facilitator", DEFAULT_FACILITATOR_URL);
 
-        this.max_num_proxy_pairs = get_param_integer(query, "max_clients", DEFAULT_MAX_NUM_PROXY_PAIRS);
-        if (this.max_num_proxy_pairs === null || this.max_num_proxy_pairs < 0) {
+        this.max_num_clients = get_param_integer(query, "max_clients", DEFAULT_MAX_NUM_CLIENTS);
+        if (this.max_num_clients === null || this.max_num_clients < 0) {
             puts("Error: max_clients must be a nonnegative integer.");
             this.die();
             return;
@@ -562,7 +566,7 @@ function FlashProxy() {
         var base_url, url;
         var xhr;
 
-        if (this.proxy_pairs.length >= this.max_num_proxy_pairs) {
+        if (this.proxy_pairs.length >= this.max_num_clients * CONNECTIONS_PER_CLIENT) {
             setTimeout(this.proxy_main.bind(this), this.facilitator_poll_interval * 1000);
             return;
         }
@@ -657,12 +661,9 @@ function FlashProxy() {
     };
 
     this.begin_proxy = function(client_addr, relay_addr) {
-        /* Start two proxy connections because of some versions of Tor making
-           two pt connections:
-           https://lists.torproject.org/pipermail/tor-dev/2012-December/004221.html
-           https://trac.torproject.org/projects/tor/ticket/7733 */
-        this.make_proxy_pair(client_addr, relay_addr);
-        this.make_proxy_pair(client_addr, relay_addr);
+        for (var i=0; i<CONNECTIONS_PER_CLIENT; i++) {
+            this.make_proxy_pair(client_addr, relay_addr);
+        }
     };
 
     this.make_proxy_pair = function(client_addr, relay_addr) {





More information about the tor-commits mailing list