mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
Fix some linting warnings for "Line exceeds maximum allowed length."
This commit is contained in:
parent
5384ef9d16
commit
dad53932a2
7 changed files with 27 additions and 12 deletions
|
@ -21,7 +21,9 @@ init = () ->
|
||||||
config = new Config
|
config = new Config
|
||||||
|
|
||||||
if 'off' != query['ratelimit']
|
if 'off' != query['ratelimit']
|
||||||
config.rateLimitBytes = Params.getByteCount(query, 'ratelimit', config.rateLimitBytes)
|
config.rateLimitBytes = Params.getByteCount(
|
||||||
|
query,'ratelimit', config.rateLimitBytes
|
||||||
|
)
|
||||||
|
|
||||||
ui = null
|
ui = null
|
||||||
if (document.getElementById('badge') != null)
|
if (document.getElementById('badge') != null)
|
||||||
|
|
|
@ -82,7 +82,10 @@ class Snowflake
|
||||||
recv = @broker.getClientOffer pair.id
|
recv = @broker.getClientOffer pair.id
|
||||||
recv.then (desc) =>
|
recv.then (desc) =>
|
||||||
@receiveOffer pair, desc
|
@receiveOffer pair, desc
|
||||||
countdown('Serving 1 new client.', @config.defaultBrokerPollInterval / 1000)
|
countdown(
|
||||||
|
'Serving 1 new client.',
|
||||||
|
@config.defaultBrokerPollInterval / 1000
|
||||||
|
)
|
||||||
, (err) =>
|
, (err) =>
|
||||||
countdown(err, @config.defaultBrokerPollInterval / 1000)
|
countdown(err, @config.defaultBrokerPollInterval / 1000)
|
||||||
@retries++
|
@retries++
|
||||||
|
|
|
@ -96,7 +96,9 @@ describe 'ProxyPair', ->
|
||||||
}
|
}
|
||||||
spyOn pp.client, 'send'
|
spyOn pp.client, 'send'
|
||||||
spyOn pp.relay, 'send'
|
spyOn pp.relay, 'send'
|
||||||
msg = new MessageEvent("message", { data: Uint8Array.from([1, 2, 3]).buffer })
|
msg = new MessageEvent("message", {
|
||||||
|
data: Uint8Array.from([1, 2, 3]).buffer
|
||||||
|
})
|
||||||
pp.onClientToRelayMessage(msg)
|
pp.onClientToRelayMessage(msg)
|
||||||
pp.flush()
|
pp.flush()
|
||||||
expect(pp.client.send).not.toHaveBeenCalled()
|
expect(pp.client.send).not.toHaveBeenCalled()
|
||||||
|
@ -105,7 +107,9 @@ describe 'ProxyPair', ->
|
||||||
it 'proxies data from relay to client', ->
|
it 'proxies data from relay to client', ->
|
||||||
spyOn pp.client, 'send'
|
spyOn pp.client, 'send'
|
||||||
spyOn pp.relay, 'send'
|
spyOn pp.relay, 'send'
|
||||||
msg = new MessageEvent("message", { data: Uint8Array.from([4, 5, 6]).buffer })
|
msg = new MessageEvent("message", {
|
||||||
|
data: Uint8Array.from([4, 5, 6]).buffer
|
||||||
|
})
|
||||||
pp.onRelayToClientMessage(msg)
|
pp.onRelayToClientMessage(msg)
|
||||||
pp.flush()
|
pp.flush()
|
||||||
expect(pp.client.send).toHaveBeenCalledWith arrayMatching([4, 5, 6])
|
expect(pp.client.send).toHaveBeenCalledWith arrayMatching([4, 5, 6])
|
||||||
|
|
|
@ -118,6 +118,7 @@ describe 'Parse', ->
|
||||||
expected: '1.2.3.4'
|
expected: '1.2.3.4'
|
||||||
,
|
,
|
||||||
# Modified from SDP sent by snowflake-client.
|
# Modified from SDP sent by snowflake-client.
|
||||||
|
# coffeelint: disable
|
||||||
sdp: """
|
sdp: """
|
||||||
v=0
|
v=0
|
||||||
o=- 7860378660295630295 2 IN IP4 127.0.0.1
|
o=- 7860378660295630295 2 IN IP4 127.0.0.1
|
||||||
|
@ -137,6 +138,7 @@ describe 'Parse', ->
|
||||||
a=mid:data
|
a=mid:data
|
||||||
a=sctpmap:5000 webrtc-datachannel 1024
|
a=sctpmap:5000 webrtc-datachannel 1024
|
||||||
"""
|
"""
|
||||||
|
# coffeelint: enable
|
||||||
expected: '1.2.3.4'
|
expected: '1.2.3.4'
|
||||||
,
|
,
|
||||||
# Improper character within IPv4
|
# Improper character within IPv4
|
||||||
|
@ -164,7 +166,9 @@ describe 'Parse', ->
|
||||||
# We represent the test cases with LF line endings for convenience, and
|
# We represent the test cases with LF line endings for convenience, and
|
||||||
# test them both that way and with CRLF line endings.
|
# test them both that way and with CRLF line endings.
|
||||||
expect(Parse.ipFromSDP(test.sdp)?.toLowerCase()).toEqual(test.expected)
|
expect(Parse.ipFromSDP(test.sdp)?.toLowerCase()).toEqual(test.expected)
|
||||||
expect(Parse.ipFromSDP(test.sdp.replace(/\n/, "\r\n"))?.toLowerCase()).toEqual(test.expected)
|
expect(
|
||||||
|
Parse.ipFromSDP(test.sdp.replace(/\n/, "\r\n"))?.toLowerCase()
|
||||||
|
).toEqual(test.expected)
|
||||||
|
|
||||||
describe 'query string', ->
|
describe 'query string', ->
|
||||||
it 'should parse correctly', ->
|
it 'should parse correctly', ->
|
||||||
|
|
|
@ -24,8 +24,9 @@ describe 'BuildUrl', ->
|
||||||
it 'should handle params', ->
|
it 'should handle params', ->
|
||||||
expect WS.buildUrl 'http', 'example.com', 80, '/test', [['k', '%#v']]
|
expect WS.buildUrl 'http', 'example.com', 80, '/test', [['k', '%#v']]
|
||||||
.toBe 'http://example.com/test?k=%25%23v'
|
.toBe 'http://example.com/test?k=%25%23v'
|
||||||
expect WS.buildUrl 'http', 'example.com', 80, '/test', [['a', 'b'], ['c', 'd']]
|
expect(WS.buildUrl(
|
||||||
.toBe 'http://example.com/test?a=b&c=d'
|
'http', 'example.com', 80, '/test', [['a', 'b'], ['c', 'd']]
|
||||||
|
)).toBe 'http://example.com/test?a=b&c=d'
|
||||||
it 'should handle ips', ->
|
it 'should handle ips', ->
|
||||||
expect WS.buildUrl 'http', '1.2.3.4'
|
expect WS.buildUrl 'http', '1.2.3.4'
|
||||||
.toBe 'http://1.2.3.4'
|
.toBe 'http://1.2.3.4'
|
||||||
|
|
|
@ -124,8 +124,8 @@ class Parse
|
||||||
return null if null == units
|
return null if null == units
|
||||||
count * Number(units)
|
count * Number(units)
|
||||||
|
|
||||||
# Parse a connection-address out of the "c=" Connection Data field of a session
|
# Parse a connection-address out of the "c=" Connection Data field of a
|
||||||
# description. Return undefined if none is found.
|
# session description. Return undefined if none is found.
|
||||||
# https://tools.ietf.org/html/rfc4566#section-5.7
|
# https://tools.ietf.org/html/rfc4566#section-5.7
|
||||||
@ipFromSDP: (sdp) ->
|
@ipFromSDP: (sdp) ->
|
||||||
for pattern in [
|
for pattern in [
|
||||||
|
|
|
@ -52,9 +52,10 @@ class WS
|
||||||
url = @buildUrl wsProtocol, addr.host, addr.port, '/', params
|
url = @buildUrl wsProtocol, addr.host, addr.port, '/', params
|
||||||
ws = new WebSocket url
|
ws = new WebSocket url
|
||||||
###
|
###
|
||||||
'User agents can use this as a hint for how to handle incoming binary data: if
|
'User agents can use this as a hint for how to handle incoming binary data:
|
||||||
the attribute is set to 'blob', it is safe to spool it to disk, and if it is
|
if the attribute is set to 'blob', it is safe to spool it to disk, and if it
|
||||||
set to 'arraybuffer', it is likely more efficient to keep the data in memory.'
|
is set to 'arraybuffer', it is likely more efficient to keep the data in
|
||||||
|
memory.'
|
||||||
###
|
###
|
||||||
ws.binaryType = 'arraybuffer'
|
ws.binaryType = 'arraybuffer'
|
||||||
ws
|
ws
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue