[tor-commits] [snowflake/master] snowflake reset works correctly without copy paste condition,

serene at torproject.org serene at torproject.org
Mon Jan 25 18:33:20 UTC 2016


commit e1f6c7fc5d5be29d66e79a9970cdfba4e26d6baa
Author: Serene Han <keroserene+git at gmail.com>
Date:   Mon Jan 25 10:20:20 2016 -0800

    snowflake reset works correctly without copy paste condition,
    and use default broker poll interval of 5s
---
 proxy/README.md        |    2 +-
 proxy/snowflake.coffee |   12 +++++-------
 proxy/websocket.coffee |    3 +++
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/proxy/README.md b/proxy/README.md
index 386d686..1affaca 100644
--- a/proxy/README.md
+++ b/proxy/README.md
@@ -21,5 +21,5 @@ Here are optional parameters to include in the query string.
 ```
 manual - enables copy-paste signalling mode.
 relay=<address> - use a custom target relay.
-broker=<address> - use a custom broker.
+broker=<url> - use a custom broker.
 ```
diff --git a/proxy/snowflake.coffee b/proxy/snowflake.coffee
index addbaba..582de39 100644
--- a/proxy/snowflake.coffee
+++ b/proxy/snowflake.coffee
@@ -12,9 +12,6 @@ DEFAULT_RELAY =
   host: '192.81.135.242'
   port: 9901
 COPY_PASTE_ENABLED = false
-DEFAULT_PORTS =
-  http:  80
-  https: 443
 
 DEBUG = false
 query = null
@@ -29,6 +26,7 @@ HEADLESS = 'undefined' == typeof(document)
 DEFAULT_RATE_LIMIT = DEFAULT_RATE_LIMIT || undefined
 MIN_RATE_LIMIT = 10 * 1024
 RATE_LIMIT_HISTORY = 5.0
+DEFAULT_BROKER_POLL_INTERVAL = 5.0 * 1000
 
 MAX_NUM_CLIENTS = 1
 CONNECTIONS_PER_CLIENT = 1
@@ -92,12 +90,12 @@ class Snowflake
     return true
 
   # Initialize WebRTC PeerConnection
-  beginWebRTC: (automatic) ->
+  beginWebRTC: ->
     @state = MODE.WEBRTC_CONNECTING
     for i in [1..CONNECTIONS_PER_CLIENT]
       @makeProxyPair @relayAddr
     @proxyPair = @proxyPairs[0]
-    return if !automatic
+    return if COPY_PASTE_ENABLED
     # Poll broker for clients.
     findClients = =>
       recv = broker.getClientOffer()
@@ -107,7 +105,7 @@ class Snowflake
         @receiveOffer offer
       , (err) ->
         log err
-        setTimeout(findClients, 1000)
+        setTimeout(findClients, DEFAULT_BROKER_POLL_INTERVAL)
     findClients()
 
   # Receive an SDP offer from some client assigned by the Broker.
@@ -233,6 +231,6 @@ init = ->
 
   relayAddr = Params.getAddress(query, 'relay', DEFAULT_RELAY)
   snowflake.setRelayAddr relayAddr
-  snowflake.beginWebRTC(!COPY_PASTE_ENABLED)
+  snowflake.beginWebRTC()
 
 window.onload = init if window
diff --git a/proxy/websocket.coffee b/proxy/websocket.coffee
index b82f902..eca6f2a 100644
--- a/proxy/websocket.coffee
+++ b/proxy/websocket.coffee
@@ -2,6 +2,9 @@
 Only websocket-specific stuff.
 ###
 
+DEFAULT_PORTS =
+  http:  80
+  https: 443
 
 # Build an escaped URL string from unescaped components. Only scheme and host
 # are required. See RFC 3986, section 3.



More information about the tor-commits mailing list