mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 11:11:30 -04:00
snowflake terminal turns green when connected
This commit is contained in:
parent
30e7ba79ae
commit
e433af26f8
4 changed files with 25 additions and 18 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -8,3 +8,5 @@ client/client
|
|||
server/server
|
||||
snowflake.log
|
||||
proxy/test
|
||||
proxy/build
|
||||
ignore/
|
||||
|
|
|
@ -62,7 +62,8 @@ snowflake to use a default relay.
|
|||
|
||||
Look for the offer in terminal C; copy and paste it into the browser.
|
||||
Copy and paste the answer generated in the browser back to terminal B.
|
||||
At this point the tor client should bootstrap to 100%.
|
||||
Once WebRTC successfully connects, the browser terminal should turn green.
|
||||
Shortly after, the tor client should bootstrap to 100%.
|
||||
|
||||
|
||||
### More
|
||||
|
|
|
@ -148,6 +148,12 @@ RATE_LIMIT_HISTORY = 5.0
|
|||
DEFAULT_PORTS =
|
||||
http: 80
|
||||
https: 443
|
||||
|
||||
# DOM elements.
|
||||
$msglog = null
|
||||
$send = null
|
||||
$input = null
|
||||
|
||||
# Build an escaped URL string from unescaped components. Only scheme and host
|
||||
# are required. See RFC 3986, section 3.
|
||||
buildUrl = (scheme, host, port, path, params) ->
|
||||
|
@ -243,10 +249,6 @@ config = {
|
|||
]
|
||||
}
|
||||
|
||||
# DOM elements
|
||||
$chatlog = null
|
||||
$send = null
|
||||
$input = null
|
||||
|
||||
# TODO: Implement
|
||||
class Badge
|
||||
|
@ -411,13 +413,14 @@ class ProxyPair
|
|||
channel.onopen = =>
|
||||
log 'Data channel opened!'
|
||||
snowflake.state = MODE.WEBRTC_READY
|
||||
$msglog.className = 'active';
|
||||
# This is the point when the WebRTC datachannel is done, so the next step
|
||||
# is to establish websocket to the server.
|
||||
@connectRelay()
|
||||
channel.onclose = =>
|
||||
log 'Data channel closed.'
|
||||
@state = MODE.INIT;
|
||||
$chatlog.className = ''
|
||||
snowflake.state = MODE.INIT;
|
||||
$msglog.className = ''
|
||||
channel.onerror = =>
|
||||
log 'Data channel error!'
|
||||
channel.onmessage = @onClientToRelayMessage
|
||||
|
@ -471,11 +474,12 @@ class ProxyPair
|
|||
relayIsReady: -> (null != @relay) && (WebSocket.OPEN == @relay.readyState)
|
||||
isClosed: (ws) -> undefined == ws || WebSocket.CLOSED == ws.readyState
|
||||
close: ->
|
||||
@client.close() if !(isClosed @client)
|
||||
@relay.close() if !(isClosed @relay)
|
||||
@client.close() if @webrtcIsReady()
|
||||
@relay.close() if @relayIsReady()
|
||||
relay = null
|
||||
|
||||
maybeCleanup: =>
|
||||
if @running && @isClosed @relay
|
||||
if @running
|
||||
@running = false
|
||||
# TODO: Call external callback
|
||||
true
|
||||
|
@ -518,9 +522,9 @@ welcome = ->
|
|||
log = (msg) ->
|
||||
console.log msg
|
||||
# Scroll to latest
|
||||
if $chatlog
|
||||
$chatlog.value += msg + '\n'
|
||||
$chatlog.scrollTop = $chatlog.scrollHeight
|
||||
if $msglog
|
||||
$msglog.value += msg + '\n'
|
||||
$msglog.scrollTop = $msglog.scrollHeight
|
||||
|
||||
Interface =
|
||||
# Local input from keyboard into message window.
|
||||
|
@ -564,8 +568,8 @@ Signalling =
|
|||
|
||||
init = ->
|
||||
|
||||
$chatlog = document.getElementById('chatlog')
|
||||
$chatlog.value = ''
|
||||
$msglog = document.getElementById('msglog')
|
||||
$msglog.value = ''
|
||||
|
||||
$send = document.getElementById('send')
|
||||
$send.onclick = Interface.acceptInput
|
||||
|
|
|
@ -31,8 +31,8 @@
|
|||
width: 50%; min-width: 40em;
|
||||
padding: 0.5em; margin: auto;
|
||||
}
|
||||
.active { background-color: #252; }
|
||||
#chatlog {
|
||||
.active { background-color: rgba(0,50,0,0.8); }
|
||||
#msglog {
|
||||
display: block;
|
||||
width: 100%;
|
||||
min-height: 40em;
|
||||
|
@ -67,7 +67,7 @@
|
|||
</head>
|
||||
<body>
|
||||
<div class="chatarea">
|
||||
<textarea id="chatlog" readonly>
|
||||
<textarea id="msglog" readonly>
|
||||
</textarea>
|
||||
<div class="inputarea">
|
||||
<input type="text" id="input">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue