+ 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 moremaster
parent
3825d3857c
commit
ce2095d7f8
|
@ -37,6 +37,9 @@ Please note: endpoints that simply provide static web app files are not document
|
||||||
* /getblockheader/hash
|
* /getblockheader/hash
|
||||||
- Methods: GET
|
- Methods: GET
|
||||||
- Returns the header (metadata section) of a block.
|
- 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
|
* /lastconnect
|
||||||
- Methods: GET
|
- Methods: GET
|
||||||
- Returns the epoch timestamp of when the last incoming connection to the public API server was logged
|
- Returns the epoch timestamp of when the last incoming connection to the public API server was logged
|
||||||
|
|
|
@ -76,6 +76,7 @@ class PublicAPI:
|
||||||
self.i2pAdder = clientAPI._core.i2pAddress
|
self.i2pAdder = clientAPI._core.i2pAddress
|
||||||
self.bindPort = config.get('client.public.port')
|
self.bindPort = config.get('client.public.port')
|
||||||
self.lastRequest = 0
|
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))
|
logger.info('Running public api on %s:%s' % (self.host, self.bindPort))
|
||||||
|
|
||||||
@app.before_request
|
@app.before_request
|
||||||
|
@ -90,6 +91,7 @@ class PublicAPI:
|
||||||
if request.host not in (self.i2pAdder, self.torAdder):
|
if request.host not in (self.i2pAdder, self.torAdder):
|
||||||
# Disallow connection if wrong HTTP hostname, in order to prevent DNS rebinding attacks
|
# Disallow connection if wrong HTTP hostname, in order to prevent DNS rebinding attacks
|
||||||
abort(403)
|
abort(403)
|
||||||
|
self.hitCount += 1 # raise hit count for valid requests
|
||||||
|
|
||||||
@app.after_request
|
@app.after_request
|
||||||
def sendHeaders(resp):
|
def sendHeaders(resp):
|
||||||
|
@ -295,6 +297,10 @@ class API:
|
||||||
abort(403)
|
abort(403)
|
||||||
return send_from_directory(config.get('www.private.path', 'static-data/www/private/'), path)
|
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'])
|
@app.route('/queueResponseAdd/<name>', methods=['post'])
|
||||||
def queueResponseAdd(name):
|
def queueResponseAdd(name):
|
||||||
# Responses from the daemon. TODO: change to direct var access instead of http endpoint
|
# Responses from the daemon. TODO: change to direct var access instead of http endpoint
|
||||||
|
|
|
@ -72,7 +72,6 @@ class NetController:
|
||||||
hsVer = '# v2 onions'
|
hsVer = '# v2 onions'
|
||||||
if config.get('tor.v3onions'):
|
if config.get('tor.v3onions'):
|
||||||
hsVer = 'HiddenServiceVersion 3'
|
hsVer = 'HiddenServiceVersion 3'
|
||||||
logger.debug('Using v3 onions')
|
|
||||||
|
|
||||||
if os.path.exists(self.torConfigLocation):
|
if os.path.exists(self.torConfigLocation):
|
||||||
os.remove(self.torConfigLocation)
|
os.remove(self.torConfigLocation)
|
||||||
|
|
|
@ -39,7 +39,7 @@ def show_stats(o_inst):
|
||||||
|
|
||||||
# count stats
|
# count stats
|
||||||
'div2' : True,
|
'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/'))),
|
'Enabled Plugins' : str(len(o_inst.onionrCore.config.get('plugins.enabled', list()))) + ' / ' + str(len(os.listdir(o_inst.dataDir + 'plugins/'))),
|
||||||
'Stored Blocks' : str(totalBlocks),
|
'Stored Blocks' : str(totalBlocks),
|
||||||
'Percent Blocks Signed' : str(round(100 * signedBlocks / max(totalBlocks, 1), 2)) + '%'
|
'Percent Blocks Signed' : str(round(100 * signedBlocks / max(totalBlocks, 1), 2)) + '%'
|
||||||
|
|
|
@ -389,8 +389,6 @@ def commandInstallPlugin():
|
||||||
pkobh = distributor
|
pkobh = distributor
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warn('Failed to lookup plugin in repositories.', timestamp = False)
|
logger.warn('Failed to lookup plugin in repositories.', timestamp = False)
|
||||||
logger.error('asdf', error = e, timestamp = False)
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
if pkobh is None:
|
if pkobh is None:
|
||||||
|
|
|
@ -303,8 +303,9 @@ def add_deleted(keyStore, bHash):
|
||||||
keyStore.put('deleted_mail', existing.append(bHash))
|
keyStore.put('deleted_mail', existing.append(bHash))
|
||||||
|
|
||||||
def on_insertblock(api, data={}):
|
def on_insertblock(api, data={}):
|
||||||
sentboxTools = sentboxdb.SentBox(api.get_core())
|
|
||||||
meta = json.loads(data['meta'])
|
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'])
|
sentboxTools.addToSent(data['hash'], data['peer'], data['content'], meta['subject'])
|
||||||
|
|
||||||
def on_init(api, data = None):
|
def on_init(api, data = None):
|
||||||
|
|
|
@ -2,17 +2,16 @@
|
||||||
"general" : {
|
"general" : {
|
||||||
"dev_mode" : true,
|
"dev_mode" : true,
|
||||||
"display_header" : false,
|
"display_header" : false,
|
||||||
"minimum_block_pow": 4,
|
"minimum_block_pow" : 4,
|
||||||
"minimum_send_pow": 4,
|
"minimum_send_pow" : 4,
|
||||||
"use_subprocess_pow_if_possible": true,
|
"use_subprocess_pow_if_possible" : true,
|
||||||
"socket_servers": false,
|
"socket_servers" : false,
|
||||||
"security_level": 0,
|
"security_level" : 0,
|
||||||
"hide_created_blocks": true,
|
"hide_created_blocks" : true,
|
||||||
"insert_deniable_blocks": true,
|
"insert_deniable_blocks" : true,
|
||||||
"max_block_age": 2678400,
|
"max_block_age" : 2678400,
|
||||||
"bypass_tor_check": false,
|
"public_key" : "",
|
||||||
"public_key": "",
|
"random_bind_ip" : false
|
||||||
"random_bind_ip": false
|
|
||||||
},
|
},
|
||||||
|
|
||||||
"www" : {
|
"www" : {
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
<br>
|
<br>
|
||||||
<button id='shutdownNode' class='warnBtn'>Shutdown Node</button> <button id='refreshStats' class='primaryBtn'>Refresh Stats</button>
|
<button id='shutdownNode' class='warnBtn'>Shutdown Node</button> <button id='refreshStats' class='primaryBtn'>Refresh Stats</button>
|
||||||
<br><br>
|
<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>
|
<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><br><a class='idLink' href='/mail/'>Mail</a> - <a class='idLink' href='/friends/'>Friend Manager</a> - <a class='idLink' href='/board/'>Boards</a> -
|
<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>
|
<button class='saveConfig successBtn'>Save Config</button>
|
||||||
</details>
|
</details>
|
||||||
<hr>
|
<hr>
|
||||||
<h2>Stats</h2>
|
<h1>Statistics</h1>
|
||||||
<p>🕰️ Uptime: <span id='uptime'></span></p>
|
<p>🕰️ Uptime: <span id='uptime'></span></p>
|
||||||
<p>🖇️ Last Received Connection: <span id='lastIncoming'>None since start</span></p>
|
<h2>Connections</h2>
|
||||||
<p>💾 Stored Blocks: <span id='storedBlocks'></span></p>
|
<p>🖇️ Last Received Request: <span id='lastIncoming'>None since start</span></p>
|
||||||
<p>📨 Blocks in queue: <span id='blockQueue'></span></p>
|
<p>⬇️ Total Requests Received: <span id='totalRec'>None since start</span></p>
|
||||||
<p>🔗 Outgoing Connections:</p>
|
<p>🔗 Outgoing Connections:</p>
|
||||||
<pre id='connectedNodes'></pre>
|
<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>
|
</div>
|
||||||
<script src='/shared/misc.js'></script>
|
<script src='/shared/misc.js'></script>
|
||||||
<script src='/shared/main/stats.js'></script>
|
<script src='/shared/main/stats.js'></script>
|
||||||
|
|
|
@ -21,6 +21,7 @@ connectedDisplay = document.getElementById('connectedNodes')
|
||||||
storedBlockDisplay = document.getElementById('storedBlocks')
|
storedBlockDisplay = document.getElementById('storedBlocks')
|
||||||
queuedBlockDisplay = document.getElementById('blockQueue')
|
queuedBlockDisplay = document.getElementById('blockQueue')
|
||||||
lastIncoming = document.getElementById('lastIncoming')
|
lastIncoming = document.getElementById('lastIncoming')
|
||||||
|
totalRec = document.getElementById('totalRec')
|
||||||
|
|
||||||
function getStats(){
|
function getStats(){
|
||||||
stats = JSON.parse(httpGet('getstats', webpass))
|
stats = JSON.parse(httpGet('getstats', webpass))
|
||||||
|
@ -28,11 +29,13 @@ function getStats(){
|
||||||
connectedDisplay.innerText = stats['connectedNodes']
|
connectedDisplay.innerText = stats['connectedNodes']
|
||||||
storedBlockDisplay.innerText = stats['blockCount']
|
storedBlockDisplay.innerText = stats['blockCount']
|
||||||
queuedBlockDisplay.innerText = stats['blockQueueCount']
|
queuedBlockDisplay.innerText = stats['blockQueueCount']
|
||||||
|
totalRec.innerText = httpGet('/hitcount')
|
||||||
var lastConnect = httpGet('/lastconnect')
|
var lastConnect = httpGet('/lastconnect')
|
||||||
if (lastConnect > 0){
|
if (lastConnect > 0){
|
||||||
var humanDate = new Date(0)
|
var humanDate = new Date(0)
|
||||||
humanDate.setUTCSeconds(httpGet('/lastconnect'))
|
humanDate.setUTCSeconds(httpGet('/lastconnect'))
|
||||||
lastConnect = humanDate.toString()
|
humanDate = humanDate.toString()
|
||||||
|
lastConnect = humanDate.substring(0, humanDate.indexOf('('));
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
lastConnect = 'None since start'
|
lastConnect = 'None since start'
|
||||||
|
|
|
@ -46,7 +46,7 @@ body{
|
||||||
margin-left: 1%;
|
margin-left: 1%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.logoText, h1, h2{
|
.logoText, h1, h2, h3{
|
||||||
font-family: Verdana, Geneva, Tahoma, sans-serif;
|
font-family: Verdana, Geneva, Tahoma, sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue