mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-14 14:11:23 -04:00
per-proxypair Snowflake ID generation instead of just one for the Broker (#11)
This commit is contained in:
parent
422717f36f
commit
b1e76420bd
5 changed files with 44 additions and 23 deletions
|
@ -3,6 +3,8 @@ Represents a single:
|
|||
|
||||
client <-- webrtc --> snowflake <-- websocket --> relay
|
||||
|
||||
Every ProxyPair has a Snowflake ID, which is necessary when responding to the
|
||||
Broker with an WebRTC answer.
|
||||
###
|
||||
|
||||
class ProxyPair
|
||||
|
@ -16,10 +18,12 @@ class ProxyPair
|
|||
running: true
|
||||
active: false # Whether serving a client.
|
||||
flush_timeout_id: null
|
||||
onCleanup: null
|
||||
onCleanup: null
|
||||
id: null
|
||||
|
||||
constructor: (@clientAddr, @relayAddr, @rateLimit) ->
|
||||
@active = false
|
||||
@id = genSnowflakeID()
|
||||
|
||||
# Prepare a WebRTC PeerConnection and await for an SDP offer.
|
||||
begin: ->
|
||||
|
@ -38,7 +42,7 @@ class ProxyPair
|
|||
if COPY_PASTE_ENABLED
|
||||
Signalling.send @pc.localDescription
|
||||
else
|
||||
snowflake.broker.sendAnswer @pc.localDescription
|
||||
snowflake.broker.sendAnswer @id, @pc.localDescription
|
||||
# OnDataChannel triggered remotely from the client when connection succeeds.
|
||||
@pc.ondatachannel = (dc) =>
|
||||
channel = dc.channel
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue