mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
Initialize arrays when constructing
Otherwise, this is set on the prototype and shared across instances :/ Note the change to the test that highlights this bug. A proxy pair was already created when an earlier test called `beginWebRTC()` but a new Snowflake instance should start with an empty array.
This commit is contained in:
parent
9df66b15b1
commit
3839c2e0b1
3 changed files with 4 additions and 5 deletions
|
@ -10,8 +10,6 @@ Broker with an WebRTC answer.
|
||||||
class ProxyPair
|
class ProxyPair
|
||||||
MAX_BUFFER: 10 * 1024 * 1024
|
MAX_BUFFER: 10 * 1024 * 1024
|
||||||
pc: null
|
pc: null
|
||||||
c2rSchedule: []
|
|
||||||
r2cSchedule: []
|
|
||||||
client: null # WebRTC Data channel
|
client: null # WebRTC Data channel
|
||||||
relay: null # websocket
|
relay: null # websocket
|
||||||
timer: 0
|
timer: 0
|
||||||
|
@ -27,8 +25,9 @@ class ProxyPair
|
||||||
- @rateLimit specifies a rate limit on traffic
|
- @rateLimit specifies a rate limit on traffic
|
||||||
###
|
###
|
||||||
constructor: (@relayAddr, @rateLimit) ->
|
constructor: (@relayAddr, @rateLimit) ->
|
||||||
@active = false
|
|
||||||
@id = Util.genSnowflakeID()
|
@id = Util.genSnowflakeID()
|
||||||
|
@c2rSchedule = []
|
||||||
|
@r2cSchedule = []
|
||||||
|
|
||||||
# Prepare a WebRTC PeerConnection and await for an SDP offer.
|
# Prepare a WebRTC PeerConnection and await for an SDP offer.
|
||||||
begin: ->
|
begin: ->
|
||||||
|
|
|
@ -12,7 +12,6 @@ TODO: More documentation
|
||||||
# Minimum viable snowflake for now - just 1 client.
|
# Minimum viable snowflake for now - just 1 client.
|
||||||
class Snowflake
|
class Snowflake
|
||||||
relayAddr: null
|
relayAddr: null
|
||||||
proxyPairs: []
|
|
||||||
rateLimit: null
|
rateLimit: null
|
||||||
retries: 0
|
retries: 0
|
||||||
|
|
||||||
|
@ -25,6 +24,7 @@ class Snowflake
|
||||||
# Prepare the Snowflake with a Broker (to find clients) and optional UI.
|
# Prepare the Snowflake with a Broker (to find clients) and optional UI.
|
||||||
constructor: (@broker, @ui) ->
|
constructor: (@broker, @ui) ->
|
||||||
@state = Snowflake.MODE.INIT
|
@state = Snowflake.MODE.INIT
|
||||||
|
@proxyPairs = []
|
||||||
|
|
||||||
rateLimitBytes = undefined
|
rateLimitBytes = undefined
|
||||||
if 'off' != query['ratelimit']
|
if 'off' != query['ratelimit']
|
||||||
|
|
|
@ -68,7 +68,7 @@ describe 'Snowflake', ->
|
||||||
it 'can make a proxypair', ->
|
it 'can make a proxypair', ->
|
||||||
s = new Snowflake(new FakeBroker(), fakeUI)
|
s = new Snowflake(new FakeBroker(), fakeUI)
|
||||||
s.makeProxyPair()
|
s.makeProxyPair()
|
||||||
expect(s.proxyPairs.length).toBe 2
|
expect(s.proxyPairs.length).toBe 1
|
||||||
|
|
||||||
it 'gives a dialog when closing, only while active', ->
|
it 'gives a dialog when closing, only while active', ->
|
||||||
silenceNotifications = false
|
silenceNotifications = false
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue