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