|
|
|
@ -1,5 +1,3 @@
@@ -1,5 +1,3 @@
|
|
|
|
|
var url = "ws://127.0.0.1:7665"; |
|
|
|
|
|
|
|
|
|
var l = document.getElementById("log"); |
|
|
|
|
var c = document.getElementById("main"); |
|
|
|
|
var nodes = { |
|
|
|
@ -130,7 +128,7 @@ function tunnelCreated(tid) {
@@ -130,7 +128,7 @@ function tunnelCreated(tid) {
|
|
|
|
|
|
|
|
|
|
function logit(msg) { |
|
|
|
|
console.log(msg); |
|
|
|
|
var t = document.createTextNode(leftpad(msg, 25)); |
|
|
|
|
var t = document.createTextNode(msg); |
|
|
|
|
var e = document.createElement("div"); |
|
|
|
|
e.appendChild(t); |
|
|
|
|
l.appendChild(e); |
|
|
|
@ -138,12 +136,31 @@ function logit(msg) {
@@ -138,12 +136,31 @@ function logit(msg) {
|
|
|
|
|
l.removeChild(l.children[0]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var ws = new WebSocket(url); |
|
|
|
|
ws.onclose = function (ev) { |
|
|
|
|
function socketClosed() { |
|
|
|
|
var b = document.getElementById("connect-button"); |
|
|
|
|
b.onclick = startui |
|
|
|
|
b.value = "connect"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function startui() { |
|
|
|
|
var el = document.getElementById("ws-url"); |
|
|
|
|
var url; |
|
|
|
|
if(el) |
|
|
|
|
url = el.value; |
|
|
|
|
else |
|
|
|
|
url = "ws://127.0.0.1:7666"; |
|
|
|
|
|
|
|
|
|
var ws = new WebSocket(url); |
|
|
|
|
ws.onclose = function (ev) { |
|
|
|
|
logit("failed to connect to "+url); |
|
|
|
|
nodes = { length: 0 }; |
|
|
|
|
tpeers = { length: 0 }; |
|
|
|
|
} |
|
|
|
|
ws.onmessage = function(ev) { |
|
|
|
|
socketClosed(); |
|
|
|
|
} |
|
|
|
|
ws.onopen = function(ev) { |
|
|
|
|
logit("connected to "+url); |
|
|
|
|
} |
|
|
|
|
ws.onmessage = function(ev) { |
|
|
|
|
var j = JSON.parse(ev.data); |
|
|
|
|
if (j) { |
|
|
|
|
console.log(j); |
|
|
|
@ -169,7 +186,13 @@ ws.onmessage = function(ev) {
@@ -169,7 +186,13 @@ ws.onmessage = function(ev) {
|
|
|
|
|
logit("message: "+j.type); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
}; |
|
|
|
|
var b = document.getElementById("connect-button"); |
|
|
|
|
b.onclick = function() { |
|
|
|
|
ws.close(); |
|
|
|
|
} |
|
|
|
|
b.value = "disconnect"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function getPeer(h, us) { |
|
|
|
|
if (tpeers[h]) { |
|
|
|
|