commit 3839c2e0b118a6d569a3be1642d801c2a4efd100 Author: Arlo Breault arlolra@gmail.com Date: Wed May 8 13:29:23 2019 -0400
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. --- proxy/proxypair.coffee | 5 ++--- proxy/snowflake.coffee | 2 +- proxy/spec/snowflake.spec.coffee | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/proxy/proxypair.coffee b/proxy/proxypair.coffee index da45784..bd6850b 100644 --- a/proxy/proxypair.coffee +++ b/proxy/proxypair.coffee @@ -10,8 +10,6 @@ Broker with an WebRTC answer. class ProxyPair MAX_BUFFER: 10 * 1024 * 1024 pc: null - c2rSchedule: [] - r2cSchedule: [] client: null # WebRTC Data channel relay: null # websocket timer: 0 @@ -27,8 +25,9 @@ class ProxyPair - @rateLimit specifies a rate limit on traffic ### constructor: (@relayAddr, @rateLimit) -> - @active = false @id = Util.genSnowflakeID() + @c2rSchedule = [] + @r2cSchedule = []
# Prepare a WebRTC PeerConnection and await for an SDP offer. begin: -> diff --git a/proxy/snowflake.coffee b/proxy/snowflake.coffee index 07c90c6..9656c0b 100644 --- a/proxy/snowflake.coffee +++ b/proxy/snowflake.coffee @@ -12,7 +12,6 @@ TODO: More documentation # Minimum viable snowflake for now - just 1 client. class Snowflake relayAddr: null - proxyPairs: [] rateLimit: null retries: 0
@@ -25,6 +24,7 @@ class Snowflake # Prepare the Snowflake with a Broker (to find clients) and optional UI. constructor: (@broker, @ui) -> @state = Snowflake.MODE.INIT + @proxyPairs = []
rateLimitBytes = undefined if 'off' != query['ratelimit'] diff --git a/proxy/spec/snowflake.spec.coffee b/proxy/spec/snowflake.spec.coffee index 6986883..bb6e348 100644 --- a/proxy/spec/snowflake.spec.coffee +++ b/proxy/spec/snowflake.spec.coffee @@ -68,7 +68,7 @@ describe 'Snowflake', -> it 'can make a proxypair', -> s = new Snowflake(new FakeBroker(), fakeUI) s.makeProxyPair() - expect(s.proxyPairs.length).toBe 2 + expect(s.proxyPairs.length).toBe 1
it 'gives a dialog when closing, only while active', -> silenceNotifications = false
tor-commits@lists.torproject.org