mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-14 05:11:19 -04:00
Stop resetting after every pair closes
This commit is contained in:
parent
58d07788c7
commit
b1116a1c35
4 changed files with 11 additions and 25 deletions
|
@ -54,7 +54,7 @@ window.onbeforeunload = ->
|
||||||
null
|
null
|
||||||
|
|
||||||
window.onunload = ->
|
window.onunload = ->
|
||||||
pair.close() for pair in snowflake.proxyPairs
|
snowflake.disable()
|
||||||
null
|
null
|
||||||
|
|
||||||
window.onload = init
|
window.onload = init
|
||||||
|
|
|
@ -45,7 +45,7 @@ window.onbeforeunload = ->
|
||||||
null
|
null
|
||||||
|
|
||||||
window.onunload = ->
|
window.onunload = ->
|
||||||
pair.close() for pair in snowflake.proxyPairs
|
snowflake.disable()
|
||||||
null
|
null
|
||||||
|
|
||||||
window.onload = init
|
window.onload = init
|
||||||
|
|
|
@ -78,8 +78,6 @@ class ProxyPair
|
||||||
snowflake.state = Snowflake.MODE.INIT
|
snowflake.state = Snowflake.MODE.INIT
|
||||||
@flush()
|
@flush()
|
||||||
@close()
|
@close()
|
||||||
# TODO: Change this for multiplexing.
|
|
||||||
snowflake.reset()
|
|
||||||
channel.onerror = -> log 'Data channel error!'
|
channel.onerror = -> log 'Data channel error!'
|
||||||
channel.binaryType = "arraybuffer"
|
channel.binaryType = "arraybuffer"
|
||||||
channel.onmessage = @onClientToRelayMessage
|
channel.onmessage = @onClientToRelayMessage
|
||||||
|
@ -149,6 +147,7 @@ class ProxyPair
|
||||||
@client.close() if @webrtcIsReady()
|
@client.close() if @webrtcIsReady()
|
||||||
@relay.close() if @relayIsReady()
|
@relay.close() if @relayIsReady()
|
||||||
relay = null
|
relay = null
|
||||||
|
@onCleanup()
|
||||||
|
|
||||||
# Send as much data in both directions as the rate limit currently allows.
|
# Send as much data in both directions as the rate limit currently allows.
|
||||||
flush: =>
|
flush: =>
|
||||||
|
|
|
@ -51,8 +51,6 @@ class Snowflake
|
||||||
# process. |pollBroker| automatically arranges signalling.
|
# process. |pollBroker| automatically arranges signalling.
|
||||||
beginWebRTC: ->
|
beginWebRTC: ->
|
||||||
@state = Snowflake.MODE.WEBRTC_CONNECTING
|
@state = Snowflake.MODE.WEBRTC_CONNECTING
|
||||||
for i in [1..@config.connectionsPerClient]
|
|
||||||
@makeProxyPair @relayAddr
|
|
||||||
log 'ProxyPair Slots: ' + @proxyPairs.length
|
log 'ProxyPair Slots: ' + @proxyPairs.length
|
||||||
log 'Snowflake IDs: ' + (@proxyPairs.map (p) -> p.id).join ' | '
|
log 'Snowflake IDs: ' + (@proxyPairs.map (p) -> p.id).join ' | '
|
||||||
@pollBroker()
|
@pollBroker()
|
||||||
|
@ -82,6 +80,8 @@ class Snowflake
|
||||||
|
|
||||||
# Returns the first ProxyPair that's available to connect.
|
# Returns the first ProxyPair that's available to connect.
|
||||||
nextAvailableProxyPair: ->
|
nextAvailableProxyPair: ->
|
||||||
|
if @proxyPairs.length < @config.connectionsPerClient
|
||||||
|
return @makeProxyPair @relayAddr
|
||||||
return @proxyPairs.find (pp, i, arr) -> return !pp.active
|
return @proxyPairs.find (pp, i, arr) -> return !pp.active
|
||||||
|
|
||||||
# Receive an SDP offer from some client assigned by the Broker,
|
# Receive an SDP offer from some client assigned by the Broker,
|
||||||
|
@ -110,27 +110,14 @@ class Snowflake
|
||||||
@proxyPairs.push pair
|
@proxyPairs.push pair
|
||||||
pair.onCleanup = (event) =>
|
pair.onCleanup = (event) =>
|
||||||
# Delete from the list of active proxy pairs.
|
# Delete from the list of active proxy pairs.
|
||||||
@proxyPairs.splice(@proxyPairs.indexOf(pair), 1)
|
ind = @proxyPairs.indexOf(pair)
|
||||||
@pollBroker()
|
if ind > -1 then @proxyPairs.splice(ind, 1)
|
||||||
pair.begin()
|
pair.begin()
|
||||||
|
return pair
|
||||||
|
|
||||||
# Stop all proxypairs.
|
# Stop all proxypairs.
|
||||||
cease: ->
|
|
||||||
while @proxyPairs.length > 0
|
|
||||||
@proxyPairs.pop().close()
|
|
||||||
clearInterval(@pollInterval)
|
|
||||||
|
|
||||||
disable: ->
|
disable: ->
|
||||||
log 'Disabling Snowflake.'
|
log 'Disabling Snowflake.'
|
||||||
@cease()
|
clearInterval(@pollInterval)
|
||||||
|
while @proxyPairs.length > 0
|
||||||
die: ->
|
@proxyPairs.pop().close()
|
||||||
log 'Snowflake died.'
|
|
||||||
@cease()
|
|
||||||
|
|
||||||
# Close all existing ProxyPairs and begin finding new clients from scratch.
|
|
||||||
reset: ->
|
|
||||||
@cease()
|
|
||||||
log 'Snowflake resetting...'
|
|
||||||
@retries = 0
|
|
||||||
@beginWebRTC()
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue