added tor circuit stats to main page
parent
57f233d856
commit
5c636246fb
|
@ -26,7 +26,7 @@ import unpaddedbase32
|
|||
from httpapi import apiutils
|
||||
import onionrcrypto, config
|
||||
from netcontroller import NetController
|
||||
from serializeddata import SerializedData
|
||||
from statistics.serializeddata import SerializedData
|
||||
from onionrutils import mnemonickeys
|
||||
from onionrutils import bytesconverter
|
||||
from etc import onionrvalues
|
||||
|
|
|
@ -4,6 +4,7 @@ SSE API for node client access
|
|||
"""
|
||||
from flask import g, Blueprint
|
||||
from gevent import sleep
|
||||
#from time import sleep
|
||||
|
||||
from statistics.transports.tor import TorStats
|
||||
from .. import wrapper
|
||||
|
@ -38,9 +39,8 @@ def stream_hello():
|
|||
@private_sse_blueprint.route('/torcircuits')
|
||||
def stream_tor_circuits():
|
||||
tor_stats = g.too_many.get(TorStats)
|
||||
def stream():
|
||||
def circuit_stat_stream():
|
||||
while True:
|
||||
yield tor_stats.get_json()
|
||||
|
||||
sleep(3)
|
||||
return SSEWrapper.handle_sse_request(stream)
|
||||
yield "data: " + tor_stats.get_json() + "\n\n"
|
||||
sleep(10)
|
||||
return SSEWrapper.handle_sse_request(circuit_stat_stream)
|
||||
|
|
|
@ -25,7 +25,7 @@ from etc import onionrvalues, cleanup
|
|||
from onionrcrypto import getourkeypair
|
||||
from utils import hastor, logoheader
|
||||
from . import version
|
||||
import serializeddata
|
||||
from statistics import serializeddata
|
||||
import runtests
|
||||
from httpapi import daemoneventsapi
|
||||
"""
|
||||
|
|
|
@ -14,9 +14,11 @@
|
|||
<link rel="stylesheet" href="/gettheme">
|
||||
<script defer src="/shared/node_modules/pnotify/dist/iife/PNotify.js"></script>
|
||||
<script defer src="/shared/node_modules/pnotify/dist/iife/PNotifyButtons.js"></script>
|
||||
<script defer src="/shared/eventsource.js"></script>
|
||||
<script defer src="/shared/loadabout.js"></script>
|
||||
<script defer src="/shared/misc.js"></script>
|
||||
<script defer src="/shared/main/stats.js"></script>
|
||||
<script defer src="/shared/main/torstats.js"></script>
|
||||
<script defer src="/shared/panel.js"></script>
|
||||
<script defer src="/shared/configeditor.js"></script>
|
||||
<script defer src="/shared/sites.js"></script>
|
||||
|
@ -177,7 +179,7 @@
|
|||
</p>
|
||||
</header>
|
||||
<div class="card-content">
|
||||
<div class="content transportInfo">
|
||||
<div class="content torInfo">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -29,3 +29,7 @@
|
|||
.modal img{
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.torStats{
|
||||
color: red;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,23 @@
|
|||
var torSource = new EventSourcePolyfill("/torcircuits")
|
||||
var displays = document.getElementsByClassName('torInfo')
|
||||
|
||||
for (x = 0; x < displays.length; x++){
|
||||
displays[x].style.whiteSpace = 'pre'
|
||||
}
|
||||
|
||||
torSource.onmessage = function(e){
|
||||
let data = JSON.parse(e.data)
|
||||
let i = 0
|
||||
let displaying = true
|
||||
for (x = 0; x < displays.length; x++){
|
||||
let circuitCount = Object.keys(data).length
|
||||
let node = Object.keys(data)[0]
|
||||
if (circuitCount > 0){
|
||||
displays[x].innerText = "Using " + circuitCount + " Tor circuits with " + data[node]['nodes'][0]['finger'] + " as guard.\nGuard nick: " + data[node]['nodes'][0]['nick']
|
||||
}
|
||||
else{
|
||||
displays[x].innerText = "Using 0 Tor circuits."
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue