mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-14 05:11:19 -04:00
default to wss and some documentation updates, #40
This commit is contained in:
parent
d1ec51bfb9
commit
3fe10f3e7c
4 changed files with 23 additions and 6 deletions
|
@ -22,6 +22,11 @@ class ProxyPair
|
||||||
onCleanup: null
|
onCleanup: null
|
||||||
id: null
|
id: null
|
||||||
|
|
||||||
|
###
|
||||||
|
Constructs a ProxyPair where:
|
||||||
|
- @relayAddr is the destination relay
|
||||||
|
- @rateLimit specifies a rate limit on traffic
|
||||||
|
###
|
||||||
constructor: (@relayAddr, @rateLimit) ->
|
constructor: (@relayAddr, @rateLimit) ->
|
||||||
@active = false
|
@active = false
|
||||||
@id = genSnowflakeID()
|
@id = genSnowflakeID()
|
||||||
|
|
|
@ -1,16 +1,21 @@
|
||||||
###
|
###
|
||||||
A Coffeescript WebRTC snowflake proxy
|
A Coffeescript WebRTC snowflake proxy
|
||||||
Using Copy-paste signaling for now.
|
|
||||||
|
|
||||||
Uses WebRTC from the client, and websocket to the server.
|
Uses WebRTC from the client, and Websocket to the server.
|
||||||
|
|
||||||
Assume that the webrtc client plugin is always the offerer, in which case
|
Assume that the webrtc client plugin is always the offerer, in which case
|
||||||
this must always act as the answerer.
|
this must always act as the answerer.
|
||||||
###
|
###
|
||||||
|
|
||||||
|
# General snowflake proxy constants.
|
||||||
|
# For websocket-specific constants, see websocket.coffee.
|
||||||
DEFAULT_BROKER = 'snowflake-reg.appspot.com'
|
DEFAULT_BROKER = 'snowflake-reg.appspot.com'
|
||||||
DEFAULT_RELAY =
|
DEFAULT_RELAY =
|
||||||
host: '192.81.135.242'
|
host: 'snowflake.bamsoftware.com'
|
||||||
port: 9902
|
port: '443'
|
||||||
|
# Original non-wss relay:
|
||||||
|
# host: '192.81.135.242'
|
||||||
|
# port: 9902
|
||||||
COPY_PASTE_ENABLED = false
|
COPY_PASTE_ENABLED = false
|
||||||
COOKIE_NAME = "snowflake-allow"
|
COOKIE_NAME = "snowflake-allow"
|
||||||
|
|
||||||
|
@ -174,7 +179,7 @@ class Snowflake
|
||||||
snowflake = null
|
snowflake = null
|
||||||
|
|
||||||
# Signalling channel - just tells user to copy paste to the peer.
|
# Signalling channel - just tells user to copy paste to the peer.
|
||||||
# Eventually this should go over the broker.
|
# When copy-paste mode is not enabled, this is handled automatically by Broker.
|
||||||
Signalling =
|
Signalling =
|
||||||
send: (msg) ->
|
send: (msg) ->
|
||||||
log '---- Please copy the below to peer ----\n'
|
log '---- Please copy the below to peer ----\n'
|
||||||
|
@ -205,10 +210,14 @@ log = (msg) ->
|
||||||
|
|
||||||
dbg = (msg) -> log msg if DEBUG or snowflake.ui?.debug
|
dbg = (msg) -> log msg if DEBUG or snowflake.ui?.debug
|
||||||
|
|
||||||
|
###
|
||||||
|
Entry point.
|
||||||
|
###
|
||||||
init = (isNode) ->
|
init = (isNode) ->
|
||||||
# Hook up to the debug UI if available.
|
# Hook up to the debug UI if available.
|
||||||
ui = if isNode then null else new UI()
|
ui = if isNode then null else new UI()
|
||||||
silenceNotifications = Params.getBool(query, 'silent', false)
|
silenceNotifications = Params.getBool(query, 'silent', false)
|
||||||
|
# Establish connectivity information with the Broker.
|
||||||
brokerUrl = Params.getString(query, 'broker', DEFAULT_BROKER)
|
brokerUrl = Params.getString(query, 'broker', DEFAULT_BROKER)
|
||||||
broker = new Broker brokerUrl
|
broker = new Broker brokerUrl
|
||||||
snowflake = new Snowflake broker, ui
|
snowflake = new Snowflake broker, ui
|
||||||
|
|
|
@ -71,6 +71,7 @@ Parse =
|
||||||
m = spec.match(/^\[([\0-9a-fA-F:.]+)\]:([0-9]+)$/) if !m
|
m = spec.match(/^\[([\0-9a-fA-F:.]+)\]:([0-9]+)$/) if !m
|
||||||
# IPv4 syntax.
|
# IPv4 syntax.
|
||||||
m = spec.match(/^([0-9.]+):([0-9]+)$/) if !m
|
m = spec.match(/^([0-9.]+):([0-9]+)$/) if !m
|
||||||
|
# TODO: Domain match
|
||||||
return null if !m
|
return null if !m
|
||||||
|
|
||||||
host = m[1]
|
host = m[1]
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
Only websocket-specific stuff.
|
Only websocket-specific stuff.
|
||||||
###
|
###
|
||||||
|
|
||||||
|
WSS_ENABLED = true
|
||||||
DEFAULT_PORTS =
|
DEFAULT_PORTS =
|
||||||
http: 80
|
http: 80
|
||||||
https: 443
|
https: 443
|
||||||
|
@ -46,7 +47,8 @@ buildUrl = (scheme, host, port, path, params) ->
|
||||||
parts.join ''
|
parts.join ''
|
||||||
|
|
||||||
makeWebsocket = (addr) ->
|
makeWebsocket = (addr) ->
|
||||||
url = buildUrl 'ws', addr.host, addr.port, '/'
|
wsProtocol = if WSS_ENABLED then 'wss' else 'ws'
|
||||||
|
url = buildUrl wsProtocol, addr.host, addr.port, '/'
|
||||||
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: if
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue