snowflake terminal turns green when connected

This commit is contained in:
Serene Han 2016-01-14 15:38:46 -08:00
parent 30e7ba79ae
commit e433af26f8
4 changed files with 25 additions and 18 deletions

2
.gitignore vendored
View file

@ -8,3 +8,5 @@ client/client
server/server server/server
snowflake.log snowflake.log
proxy/test proxy/test
proxy/build
ignore/

View file

@ -62,7 +62,8 @@ snowflake to use a default relay.
Look for the offer in terminal C; copy and paste it into the browser. 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. 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 ### More

View file

@ -148,6 +148,12 @@ RATE_LIMIT_HISTORY = 5.0
DEFAULT_PORTS = DEFAULT_PORTS =
http: 80 http: 80
https: 443 https: 443
# DOM elements.
$msglog = null
$send = null
$input = null
# Build an escaped URL string from unescaped components. Only scheme and host # Build an escaped URL string from unescaped components. Only scheme and host
# are required. See RFC 3986, section 3. # are required. See RFC 3986, section 3.
buildUrl = (scheme, host, port, path, params) -> buildUrl = (scheme, host, port, path, params) ->
@ -243,10 +249,6 @@ config = {
] ]
} }
# DOM elements
$chatlog = null
$send = null
$input = null
# TODO: Implement # TODO: Implement
class Badge class Badge
@ -411,13 +413,14 @@ class ProxyPair
channel.onopen = => channel.onopen = =>
log 'Data channel opened!' log 'Data channel opened!'
snowflake.state = MODE.WEBRTC_READY snowflake.state = MODE.WEBRTC_READY
$msglog.className = 'active';
# This is the point when the WebRTC datachannel is done, so the next step # This is the point when the WebRTC datachannel is done, so the next step
# is to establish websocket to the server. # is to establish websocket to the server.
@connectRelay() @connectRelay()
channel.onclose = => channel.onclose = =>
log 'Data channel closed.' log 'Data channel closed.'
@state = MODE.INIT; snowflake.state = MODE.INIT;
$chatlog.className = '' $msglog.className = ''
channel.onerror = => channel.onerror = =>
log 'Data channel error!' log 'Data channel error!'
channel.onmessage = @onClientToRelayMessage channel.onmessage = @onClientToRelayMessage
@ -471,11 +474,12 @@ class ProxyPair
relayIsReady: -> (null != @relay) && (WebSocket.OPEN == @relay.readyState) relayIsReady: -> (null != @relay) && (WebSocket.OPEN == @relay.readyState)
isClosed: (ws) -> undefined == ws || WebSocket.CLOSED == ws.readyState isClosed: (ws) -> undefined == ws || WebSocket.CLOSED == ws.readyState
close: -> close: ->
@client.close() if !(isClosed @client) @client.close() if @webrtcIsReady()
@relay.close() if !(isClosed @relay) @relay.close() if @relayIsReady()
relay = null
maybeCleanup: => maybeCleanup: =>
if @running && @isClosed @relay if @running
@running = false @running = false
# TODO: Call external callback # TODO: Call external callback
true true
@ -518,9 +522,9 @@ welcome = ->
log = (msg) -> log = (msg) ->
console.log msg console.log msg
# Scroll to latest # Scroll to latest
if $chatlog if $msglog
$chatlog.value += msg + '\n' $msglog.value += msg + '\n'
$chatlog.scrollTop = $chatlog.scrollHeight $msglog.scrollTop = $msglog.scrollHeight
Interface = Interface =
# Local input from keyboard into message window. # Local input from keyboard into message window.
@ -564,8 +568,8 @@ Signalling =
init = -> init = ->
$chatlog = document.getElementById('chatlog') $msglog = document.getElementById('msglog')
$chatlog.value = '' $msglog.value = ''
$send = document.getElementById('send') $send = document.getElementById('send')
$send.onclick = Interface.acceptInput $send.onclick = Interface.acceptInput

View file

@ -31,8 +31,8 @@
width: 50%; min-width: 40em; width: 50%; min-width: 40em;
padding: 0.5em; margin: auto; padding: 0.5em; margin: auto;
} }
.active { background-color: #252; } .active { background-color: rgba(0,50,0,0.8); }
#chatlog { #msglog {
display: block; display: block;
width: 100%; width: 100%;
min-height: 40em; min-height: 40em;
@ -67,7 +67,7 @@
</head> </head>
<body> <body>
<div class="chatarea"> <div class="chatarea">
<textarea id="chatlog" readonly> <textarea id="msglog" readonly>
</textarea> </textarea>
<div class="inputarea"> <div class="inputarea">
<input type="text" id="input"> <input type="text" id="input">