mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-14 14:11:23 -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
|
# port: 9902
|
||||||
COOKIE_NAME = "snowflake-allow"
|
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.
|
# 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
|
MIN_RATE_LIMIT = 10 * 1024
|
||||||
RATE_LIMIT_HISTORY = 5.0
|
RATE_LIMIT_HISTORY = 5.0
|
||||||
DEFAULT_BROKER_POLL_INTERVAL = 5.0 * 1000
|
DEFAULT_BROKER_POLL_INTERVAL = 5.0 * 1000
|
||||||
|
@ -31,7 +27,11 @@ config = {
|
||||||
|
|
||||||
CONFIRMATION_MESSAGE = 'You\'re currently serving a Tor user via Snowflake.'
|
CONFIRMATION_MESSAGE = 'You\'re currently serving a Tor user via Snowflake.'
|
||||||
|
|
||||||
|
query = Query.parse(location)
|
||||||
|
DEBUG = Params.getBool(query, 'debug', false)
|
||||||
|
|
||||||
snowflake = null
|
snowflake = null
|
||||||
|
silenceNotifications = false
|
||||||
|
|
||||||
# Log to both console and UI if applicable.
|
# Log to both console and UI if applicable.
|
||||||
# Requires that the snowflake and UI objects are hooked up in order to
|
# Requires that the snowflake and UI objects are hooked up in order to
|
||||||
|
@ -57,9 +57,13 @@ init = () ->
|
||||||
else
|
else
|
||||||
ui = new UI()
|
ui = new UI()
|
||||||
|
|
||||||
|
rateLimitBytes = undefined
|
||||||
|
if 'off' != query['ratelimit']
|
||||||
|
rateLimitBytes = Params.getByteCount(query, 'ratelimit', DEFAULT_RATE_LIMIT)
|
||||||
|
|
||||||
silenceNotifications = Params.getBool(query, 'silent', false)
|
silenceNotifications = Params.getBool(query, 'silent', false)
|
||||||
broker = new Broker BROKER
|
broker = new Broker BROKER
|
||||||
snowflake = new Snowflake broker, ui
|
snowflake = new Snowflake broker, ui, rateLimitBytes
|
||||||
|
|
||||||
log '== snowflake proxy =='
|
log '== snowflake proxy =='
|
||||||
if Util.snowflakeIsDisabled()
|
if Util.snowflakeIsDisabled()
|
||||||
|
|
|
@ -22,14 +22,10 @@ class Snowflake
|
||||||
WEBRTC_READY: 2
|
WEBRTC_READY: 2
|
||||||
|
|
||||||
# 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, rateLimitBytes) ->
|
||||||
@state = Snowflake.MODE.INIT
|
@state = Snowflake.MODE.INIT
|
||||||
@proxyPairs = []
|
@proxyPairs = []
|
||||||
|
|
||||||
rateLimitBytes = undefined
|
|
||||||
if 'off' != query['ratelimit']
|
|
||||||
rateLimitBytes = Params.getByteCount(query, 'ratelimit',
|
|
||||||
DEFAULT_RATE_LIMIT)
|
|
||||||
if undefined == rateLimitBytes
|
if undefined == rateLimitBytes
|
||||||
@rateLimit = new DummyRateLimit()
|
@rateLimit = new DummyRateLimit()
|
||||||
else
|
else
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
jasmine tests for Snowflake
|
jasmine tests for Snowflake
|
||||||
###
|
###
|
||||||
|
|
||||||
query = {}
|
|
||||||
# Fake browser functionality:
|
# Fake browser functionality:
|
||||||
class PeerConnection
|
class PeerConnection
|
||||||
setRemoteDescription: ->
|
setRemoteDescription: ->
|
||||||
|
@ -31,7 +30,6 @@ describe 'Snowflake', ->
|
||||||
|
|
||||||
it 'constructs correctly', ->
|
it 'constructs correctly', ->
|
||||||
s = new Snowflake({ fake: 'broker' }, fakeUI)
|
s = new Snowflake({ fake: 'broker' }, fakeUI)
|
||||||
query['ratelimit'] = 'off'
|
|
||||||
expect(s.rateLimit).not.toBeNull()
|
expect(s.rateLimit).not.toBeNull()
|
||||||
expect(s.broker).toEqual { fake: 'broker' }
|
expect(s.broker).toEqual { fake: 'broker' }
|
||||||
expect(s.ui).not.toBeNull()
|
expect(s.ui).not.toBeNull()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue