mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-14 05:11:19 -04:00
Move querystring access to init
This commit is contained in:
parent
3839c2e0b1
commit
edbbea1d03
3 changed files with 11 additions and 13 deletions
|
@ -9,12 +9,8 @@ RELAY =
|
|||
# port: 9902
|
||||
COOKIE_NAME = "snowflake-allow"
|
||||
|
||||
silenceNotifications = false
|
||||
query = Query.parse(location)
|
||||
DEBUG = Params.getBool(query, 'debug', false)
|
||||
|
||||
# Bytes per second. Set to undefined to disable limit.
|
||||
DEFAULT_RATE_LIMIT = DEFAULT_RATE_LIMIT || undefined
|
||||
DEFAULT_RATE_LIMIT = undefined
|
||||
MIN_RATE_LIMIT = 10 * 1024
|
||||
RATE_LIMIT_HISTORY = 5.0
|
||||
DEFAULT_BROKER_POLL_INTERVAL = 5.0 * 1000
|
||||
|
@ -31,7 +27,11 @@ config = {
|
|||
|
||||
CONFIRMATION_MESSAGE = 'You\'re currently serving a Tor user via Snowflake.'
|
||||
|
||||
query = Query.parse(location)
|
||||
DEBUG = Params.getBool(query, 'debug', false)
|
||||
|
||||
snowflake = null
|
||||
silenceNotifications = false
|
||||
|
||||
# Log to both console and UI if applicable.
|
||||
# Requires that the snowflake and UI objects are hooked up in order to
|
||||
|
@ -57,9 +57,13 @@ init = () ->
|
|||
else
|
||||
ui = new UI()
|
||||
|
||||
rateLimitBytes = undefined
|
||||
if 'off' != query['ratelimit']
|
||||
rateLimitBytes = Params.getByteCount(query, 'ratelimit', DEFAULT_RATE_LIMIT)
|
||||
|
||||
silenceNotifications = Params.getBool(query, 'silent', false)
|
||||
broker = new Broker BROKER
|
||||
snowflake = new Snowflake broker, ui
|
||||
snowflake = new Snowflake broker, ui, rateLimitBytes
|
||||
|
||||
log '== snowflake proxy =='
|
||||
if Util.snowflakeIsDisabled()
|
||||
|
|
|
@ -22,14 +22,10 @@ class Snowflake
|
|||
WEBRTC_READY: 2
|
||||
|
||||
# Prepare the Snowflake with a Broker (to find clients) and optional UI.
|
||||
constructor: (@broker, @ui) ->
|
||||
constructor: (@broker, @ui, rateLimitBytes) ->
|
||||
@state = Snowflake.MODE.INIT
|
||||
@proxyPairs = []
|
||||
|
||||
rateLimitBytes = undefined
|
||||
if 'off' != query['ratelimit']
|
||||
rateLimitBytes = Params.getByteCount(query, 'ratelimit',
|
||||
DEFAULT_RATE_LIMIT)
|
||||
if undefined == rateLimitBytes
|
||||
@rateLimit = new DummyRateLimit()
|
||||
else
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
jasmine tests for Snowflake
|
||||
###
|
||||
|
||||
query = {}
|
||||
# Fake browser functionality:
|
||||
class PeerConnection
|
||||
setRemoteDescription: ->
|
||||
|
@ -31,7 +30,6 @@ describe 'Snowflake', ->
|
|||
|
||||
it 'constructs correctly', ->
|
||||
s = new Snowflake({ fake: 'broker' }, fakeUI)
|
||||
query['ratelimit'] = 'off'
|
||||
expect(s.rateLimit).not.toBeNull()
|
||||
expect(s.broker).toEqual { fake: 'broker' }
|
||||
expect(s.ui).not.toBeNull()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue