+ added hit count stat

- removed bypass_tor_check as defunct config option
* actually fixed connect stat in cli for real this time
* improved ui stats more
master
Kevin Froman 2019-06-16 17:34:43 -05:00
parent 3825d3857c
commit ce2095d7f8
10 changed files with 36 additions and 24 deletions

View File

@ -37,6 +37,9 @@ Please note: endpoints that simply provide static web app files are not document
* /getblockheader/hash
- Methods: GET
- Returns the header (metadata section) of a block.
* /hitcount
- Methods: GET
- Return the amount of requests the public api server has received this session
* /lastconnect
- Methods: GET
- Returns the epoch timestamp of when the last incoming connection to the public API server was logged

View File

@ -76,6 +76,7 @@ class PublicAPI:
self.i2pAdder = clientAPI._core.i2pAddress
self.bindPort = config.get('client.public.port')
self.lastRequest = 0
self.hitCount = 0 # total rec requests to public api since server started
logger.info('Running public api on %s:%s' % (self.host, self.bindPort))
@app.before_request
@ -90,6 +91,7 @@ class PublicAPI:
if request.host not in (self.i2pAdder, self.torAdder):
# Disallow connection if wrong HTTP hostname, in order to prevent DNS rebinding attacks
abort(403)
self.hitCount += 1 # raise hit count for valid requests
@app.after_request
def sendHeaders(resp):
@ -295,6 +297,10 @@ class API:
abort(403)
return send_from_directory(config.get('www.private.path', 'static-data/www/private/'), path)
@app.route('/hitcount')
def get_hit_count():
return Response(str(self.publicAPI.hitCount))
@app.route('/queueResponseAdd/<name>', methods=['post'])
def queueResponseAdd(name):
# Responses from the daemon. TODO: change to direct var access instead of http endpoint

View File

@ -72,7 +72,6 @@ class NetController:
hsVer = '# v2 onions'
if config.get('tor.v3onions'):
hsVer = 'HiddenServiceVersion 3'
logger.debug('Using v3 onions')
if os.path.exists(self.torConfigLocation):
os.remove(self.torConfigLocation)

View File

@ -39,7 +39,7 @@ def show_stats(o_inst):
# count stats
'div2' : True,
'Known Peers' : str(len(o_inst.onionrCore.listPeers())),
'Known Peers' : str(max(len(o_inst.onionrCore.listPeers()) - 1, 0)),
'Enabled Plugins' : str(len(o_inst.onionrCore.config.get('plugins.enabled', list()))) + ' / ' + str(len(os.listdir(o_inst.dataDir + 'plugins/'))),
'Stored Blocks' : str(totalBlocks),
'Percent Blocks Signed' : str(round(100 * signedBlocks / max(totalBlocks, 1), 2)) + '%'

View File

@ -389,8 +389,6 @@ def commandInstallPlugin():
pkobh = distributor
except Exception as e:
logger.warn('Failed to lookup plugin in repositories.', timestamp = False)
logger.error('asdf', error = e, timestamp = False)
return True
if pkobh is None:

View File

@ -303,8 +303,9 @@ def add_deleted(keyStore, bHash):
keyStore.put('deleted_mail', existing.append(bHash))
def on_insertblock(api, data={}):
sentboxTools = sentboxdb.SentBox(api.get_core())
meta = json.loads(data['meta'])
if meta['type'] == 'pm':
sentboxTools = sentboxdb.SentBox(api.get_core())
sentboxTools.addToSent(data['hash'], data['peer'], data['content'], meta['subject'])
def on_init(api, data = None):

View File

@ -10,7 +10,6 @@
"hide_created_blocks" : true,
"insert_deniable_blocks" : true,
"max_block_age" : 2678400,
"bypass_tor_check": false,
"public_key" : "",
"random_bind_ip" : false
},

View File

@ -23,7 +23,7 @@
<br>
<button id='shutdownNode' class='warnBtn'>Shutdown Node</button> <button id='refreshStats' class='primaryBtn'>Refresh Stats</button>
<br><br>
<h2>Onionr Services</h2>
<h1>Onionr Services</h1>
<label>Open Site: <input type='text' id='siteViewer' placeholder='Site Hash'> <button id='openSite' class='primaryBtn openSiteBtn'>Open Onionr Site</button></label>
<br>
<br><br><a class='idLink' href='/mail/'>Mail</a> - <a class='idLink' href='/friends/'>Friend Manager</a> - <a class='idLink' href='/board/'>Boards</a> -
@ -38,13 +38,16 @@
<button class='saveConfig successBtn'>Save Config</button>
</details>
<hr>
<h2>Stats</h2>
<h1>Statistics</h1>
<p>🕰️ Uptime: <span id='uptime'></span></p>
<p>🖇️ Last Received Connection: <span id='lastIncoming'>None since start</span></p>
<p>💾 Stored Blocks: <span id='storedBlocks'></span></p>
<p>📨 Blocks in queue: <span id='blockQueue'></span></p>
<h2>Connections</h2>
<p>🖇️ Last Received Request: <span id='lastIncoming'>None since start</span></p>
<p>⬇️ Total Requests Received: <span id='totalRec'>None since start</span></p>
<p>🔗 Outgoing Connections:</p>
<pre id='connectedNodes'></pre>
<h2>Blocks</h2>
<p>💾 Stored Blocks: <span id='storedBlocks'></span></p>
<p>📨 Blocks in queue: <span id='blockQueue'></span></p>
</div>
<script src='/shared/misc.js'></script>
<script src='/shared/main/stats.js'></script>

View File

@ -21,6 +21,7 @@ connectedDisplay = document.getElementById('connectedNodes')
storedBlockDisplay = document.getElementById('storedBlocks')
queuedBlockDisplay = document.getElementById('blockQueue')
lastIncoming = document.getElementById('lastIncoming')
totalRec = document.getElementById('totalRec')
function getStats(){
stats = JSON.parse(httpGet('getstats', webpass))
@ -28,11 +29,13 @@ function getStats(){
connectedDisplay.innerText = stats['connectedNodes']
storedBlockDisplay.innerText = stats['blockCount']
queuedBlockDisplay.innerText = stats['blockQueueCount']
totalRec.innerText = httpGet('/hitcount')
var lastConnect = httpGet('/lastconnect')
if (lastConnect > 0){
var humanDate = new Date(0)
humanDate.setUTCSeconds(httpGet('/lastconnect'))
lastConnect = humanDate.toString()
humanDate = humanDate.toString()
lastConnect = humanDate.substring(0, humanDate.indexOf('('));
}
else{
lastConnect = 'None since start'

View File

@ -46,7 +46,7 @@ body{
margin-left: 1%;
}
.logoText, h1, h2{
.logoText, h1, h2, h3{
font-family: Verdana, Geneva, Tahoma, sans-serif;
}