mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-14 14:11:23 -04:00
parent
064875cc29
commit
81931fa8e7
1 changed files with 8 additions and 1 deletions
|
@ -15,6 +15,7 @@ class ProxyPair
|
||||||
r2cSchedule: []
|
r2cSchedule: []
|
||||||
client: null # WebRTC Data channel
|
client: null # WebRTC Data channel
|
||||||
relay: null # websocket
|
relay: null # websocket
|
||||||
|
timer: 0
|
||||||
running: true
|
running: true
|
||||||
active: false # Whether serving a client.
|
active: false # Whether serving a client.
|
||||||
flush_timeout_id: null
|
flush_timeout_id: null
|
||||||
|
@ -90,6 +91,9 @@ class ProxyPair
|
||||||
@relay = makeWebsocket @relayAddr
|
@relay = makeWebsocket @relayAddr
|
||||||
@relay.label = 'websocket-relay'
|
@relay.label = 'websocket-relay'
|
||||||
@relay.onopen = =>
|
@relay.onopen = =>
|
||||||
|
if @timer
|
||||||
|
clearTimeout @timer
|
||||||
|
@timer = 0
|
||||||
log @relay.label + ' connected!'
|
log @relay.label + ' connected!'
|
||||||
snowflake.ui.setStatus 'connected'
|
snowflake.ui.setStatus 'connected'
|
||||||
@relay.onclose = =>
|
@relay.onclose = =>
|
||||||
|
@ -102,7 +106,7 @@ class ProxyPair
|
||||||
@relay.onerror = @onError
|
@relay.onerror = @onError
|
||||||
@relay.onmessage = @onRelayToClientMessage
|
@relay.onmessage = @onRelayToClientMessage
|
||||||
# TODO: Better websocket timeout handling.
|
# TODO: Better websocket timeout handling.
|
||||||
setTimeout((=>
|
@timer = setTimeout((=>
|
||||||
log @relay.label + ' timed out connecting.'
|
log @relay.label + ' timed out connecting.'
|
||||||
@relay.onclose()), 5000)
|
@relay.onclose()), 5000)
|
||||||
|
|
||||||
|
@ -132,6 +136,9 @@ class ProxyPair
|
||||||
|
|
||||||
# Close both WebRTC and websocket.
|
# Close both WebRTC and websocket.
|
||||||
close: ->
|
close: ->
|
||||||
|
if @timer
|
||||||
|
clearTimeout @timer
|
||||||
|
@timer = 0
|
||||||
@running = false
|
@running = false
|
||||||
@client.close() if @webrtcIsReady()
|
@client.close() if @webrtcIsReady()
|
||||||
@relay.close() if @relayIsReady()
|
@relay.close() if @relayIsReady()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue