netcheck now also uses last incomming connection time

This commit is contained in:
Kevin Froman 2019-06-14 02:05:58 -05:00
parent c4fa0c15f0
commit faa79bb35c
3 changed files with 11 additions and 5 deletions

View File

@ -22,8 +22,15 @@ import logger
from utils import netutils from utils import netutils
def net_check(comm_inst): def net_check(comm_inst):
'''Check if we are connected to the internet or not when we can't connect to any peers''' '''Check if we are connected to the internet or not when we can't connect to any peers'''
rec = False # for detecting if we have received incoming connections recently
if len(comm_inst.onlinePeers) == 0: if len(comm_inst.onlinePeers) == 0:
if not netutils.checkNetwork(comm_inst._core._utils, torPort=comm_inst.proxyPort): try:
if (comm_inst._core._utils.getEpoch() - int(comm_inst._core._utils.localCommand('/lastconnect'))) <= 60:
comm_inst.isOnline = True
rec = True
except ValueError:
pass
if not rec and not netutils.checkNetwork(comm_inst._core._utils, torPort=comm_inst.proxyPort):
if not comm_inst.shutdown: if not comm_inst.shutdown:
logger.warn('Network check failed, are you connected to the Internet, and is Tor working?') logger.warn('Network check failed, are you connected to the Internet, and is Tor working?')
comm_inst.isOnline = False comm_inst.isOnline = False

View File

@ -40,7 +40,7 @@
<hr> <hr>
<h2>Stats</h2> <h2>Stats</h2>
<p>🕰️ Uptime: <span id='uptime'></span></p> <p>🕰️ Uptime: <span id='uptime'></span></p>
<p>🖇️ Last Received Connection: <span id='lastIncoming'>Unknown</span></p> <p>🖇️ Last Received Connection: <span id='lastIncoming'>None since start</span></p>
<p>💾 Stored Blocks: <span id='storedBlocks'></span></p> <p>💾 Stored Blocks: <span id='storedBlocks'></span></p>
<p>📨 Blocks in queue: <span id='blockQueue'></span></p> <p>📨 Blocks in queue: <span id='blockQueue'></span></p>
<p>🔗 Outgoing Connections:</p> <p>🔗 Outgoing Connections:</p>

View File

@ -1,6 +1,5 @@
/* /*
Onionr - Private P2P Communication
Onionr - P2P Anonymous Storage Network
This file loads stats to show on the main node web page This file loads stats to show on the main node web page
@ -36,7 +35,7 @@ function getStats(){
lastConnect = humanDate.toString() lastConnect = humanDate.toString()
} }
else{ else{
lastConnect = 'Unknown' lastConnect = 'None since start'
} }
lastIncoming.innerText = lastConnect lastIncoming.innerText = lastConnect
} }