[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [snowflake/master] Stop resetting after every pair closes
commit b1116a1c356bef91dd53f83563af49e0c422b127
Author: Arlo Breault <arlolra@xxxxxxxxx>
Date: Sat Jun 29 18:09:12 2019 -0400
Stop resetting after every pair closes
---
proxy/init-badge.coffee | 2 +-
proxy/init-webext.coffee | 2 +-
proxy/proxypair.coffee | 3 +--
proxy/snowflake.coffee | 29 ++++++++---------------------
4 files changed, 11 insertions(+), 25 deletions(-)
diff --git a/proxy/init-badge.coffee b/proxy/init-badge.coffee
index 7802ca4..eead5b0 100644
--- a/proxy/init-badge.coffee
+++ b/proxy/init-badge.coffee
@@ -54,7 +54,7 @@ window.onbeforeunload = ->
null
window.onunload = ->
- pair.close() for pair in snowflake.proxyPairs
+ snowflake.disable()
null
window.onload = init
diff --git a/proxy/init-webext.coffee b/proxy/init-webext.coffee
index 104384d..20b8bc3 100644
--- a/proxy/init-webext.coffee
+++ b/proxy/init-webext.coffee
@@ -45,7 +45,7 @@ window.onbeforeunload = ->
null
window.onunload = ->
- pair.close() for pair in snowflake.proxyPairs
+ snowflake.disable()
null
window.onload = init
diff --git a/proxy/proxypair.coffee b/proxy/proxypair.coffee
index efcc8c7..b66ba4f 100644
--- a/proxy/proxypair.coffee
+++ b/proxy/proxypair.coffee
@@ -78,8 +78,6 @@ class ProxyPair
snowflake.state = Snowflake.MODE.INIT
@flush()
@close()
- # TODO: Change this for multiplexing.
- snowflake.reset()
channel.onerror = -> log 'Data channel error!'
channel.binaryType = "arraybuffer"
channel.onmessage = @onClientToRelayMessage
@@ -149,6 +147,7 @@ class ProxyPair
@client.close() if @webrtcIsReady()
@relay.close() if @relayIsReady()
relay = null
+ @onCleanup()
# Send as much data in both directions as the rate limit currently allows.
flush: =>
diff --git a/proxy/snowflake.coffee b/proxy/snowflake.coffee
index 99dd2bd..d2fdf91 100644
--- a/proxy/snowflake.coffee
+++ b/proxy/snowflake.coffee
@@ -51,8 +51,6 @@ class Snowflake
# process. |pollBroker| automatically arranges signalling.
beginWebRTC: ->
@state = Snowflake.MODE.WEBRTC_CONNECTING
- for i in [1..@config.connectionsPerClient]
- @makeProxyPair @relayAddr
log 'ProxyPair Slots: ' + @proxyPairs.length
log 'Snowflake IDs: ' + (@proxyPairs.map (p) -> p.id).join ' | '
@pollBroker()
@@ -82,6 +80,8 @@ class Snowflake
# Returns the first ProxyPair that's available to connect.
nextAvailableProxyPair: ->
+ if @proxyPairs.length < @config.connectionsPerClient
+ return @makeProxyPair @relayAddr
return @proxyPairs.find (pp, i, arr) -> return !pp.active
# Receive an SDP offer from some client assigned by the Broker,
@@ -110,27 +110,14 @@ class Snowflake
@proxyPairs.push pair
pair.onCleanup = (event) =>
# Delete from the list of active proxy pairs.
- @proxyPairs.splice(@proxyPairs.indexOf(pair), 1)
- @pollBroker()
+ ind = @proxyPairs.indexOf(pair)
+ if ind > -1 then @proxyPairs.splice(ind, 1)
pair.begin()
+ return pair
# Stop all proxypairs.
- cease: ->
- while @proxyPairs.length > 0
- @proxyPairs.pop().close()
- clearInterval(@pollInterval)
-
disable: ->
log 'Disabling Snowflake.'
- @cease()
-
- die: ->
- log 'Snowflake died.'
- @cease()
-
- # Close all existing ProxyPairs and begin finding new clients from scratch.
- reset: ->
- @cease()
- log 'Snowflake resetting...'
- @retries = 0
- @beginWebRTC()
+ clearInterval(@pollInterval)
+ while @proxyPairs.length > 0
+ @proxyPairs.pop().close()
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits