connections now able to be created and detected in webui

This commit is contained in:
Kevin Froman 2019-08-17 02:27:33 -05:00
parent 0d9e72eccd
commit 80098d39c1
6 changed files with 31 additions and 6 deletions

2
.gitignore vendored
View File

@ -3,6 +3,8 @@ onionr/data/config.ini
onionr/data/*.db onionr/data/*.db
onionr/data-old/* onionr/data-old/*
onionr/data* onionr/data*
onionr/tor
onionr/tor.exe
onionr/testdata onionr/testdata
onionr/*.pyc onionr/*.pyc
onionr/*.log onionr/*.log

View File

@ -55,6 +55,6 @@ class DirectConnectionManagement:
"""Spawn a thread that will create the client and eventually add it to the """Spawn a thread that will create the client and eventually add it to the
communicator.active_services communicator.active_services
""" """
threading.Thread(target=onionrservices.OnionrServices().create_client, args=[pubkey, communicator]).start() threading.Thread(target=onionrservices.OnionrServices().create_client, args=[pubkey, communicator], daemon=True).start()
return Response(resp) return Response(resp)

View File

@ -85,6 +85,6 @@ def bootstrap_client_service(peer, comm_inst=None, bootstrap_timeout=300):
# This line reached when server is shutdown by being bootstrapped # This line reached when server is shutdown by being bootstrapped
# Add the address to the client pool # Add the address to the client pool
if not comm_inst is None: if not comm_inst is None:
comm_inst.direct_connection_clients[peer] = bs_id comm_inst.direct_connection_clients[peer] = response.service_id
# Now that the bootstrap server has received a server, return the address # Now that the bootstrap server has received a server, return the address
return key_store.get(bs_id) return key_store.get(bs_id)

View File

@ -13,3 +13,7 @@
.chatContent{ .chatContent{
padding-right: 5%; padding-right: 5%;
} }
.connectStatus{
float: right;
}

View File

@ -18,16 +18,33 @@
*/ */
friendList = {} friendList = {}
convoListElement = document.getElementsByClassName('conversationList')[0] convoListElement = document.getElementsByClassName('conversationList')[0]
firstConvoLoad = true
function createConvoList(){ function createConvoList(){
convoListElement.innerHTML = ""
for (friend in friendList){ for (friend in friendList){
var convoEntry = document.createElement('li') let convoEntry = document.createElement('li')
let connectStatus = document.createElement('span')
if (! firstConvoLoad){
connectStatus.innerText = " X"
connectStatus.style.color = "red"
connectStatus.classList.add("connectStatus")
console.log(direct_connections)
if (direct_connections.hasOwnProperty(friend)){
connectStatus.innerText = " ✅"
connectStatus.style.color = "green"
}
}
convoEntry.classList.add('convoEntry') convoEntry.classList.add('convoEntry')
convoEntry.setAttribute('data-pubkey', friend) convoEntry.setAttribute('data-pubkey', friend)
convoEntry.innerText = friendList[friend] convoEntry.innerText = friendList[friend]
convoEntry.appendChild(connectStatus)
convoListElement.append(convoEntry) convoListElement.append(convoEntry)
firstConvoLoad = false
} }
setTimeout(function(){createConvoList()}, 3000)
} }
fetch('/friends/list', { fetch('/friends/list', {

View File

@ -25,7 +25,7 @@ let waitForConnection = function(pubkey){
}}) }})
.then((resp) => resp.text()) .then((resp) => resp.text())
.then(function(resp) { .then(function(resp) {
if (resp.text === ""){ if (resp === ""){
// Try to get the client address again again in a few seconds // Try to get the client address again again in a few seconds
setTimeout(function(){waitForConnection(pubkey)}, 3000) setTimeout(function(){waitForConnection(pubkey)}, 3000)
} }
@ -51,9 +51,11 @@ let createConnection = function(pubkey){
}}) }})
.then((resp) => resp.text()) .then((resp) => resp.text())
.then(function(resp) { .then(function(resp) {
alert(resp)
if (resp === "pending"){ if (resp === "pending"){
setTimeout(function(){waitForConnection(pubkey)}, 3000) setTimeout(function(){waitForConnection(pubkey)}, 3000)
} }
else{
direct_connections[pubkey] = resp
}
}) })
} }