From faa79bb35ccc639cfa1bc70616866c435b33d801 Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Fri, 14 Jun 2019 02:05:58 -0500 Subject: [PATCH] netcheck now also uses last incomming connection time --- onionr/communicatorutils/netcheck.py | 9 ++++++++- onionr/static-data/www/private/index.html | 2 +- onionr/static-data/www/shared/main/stats.js | 5 ++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/onionr/communicatorutils/netcheck.py b/onionr/communicatorutils/netcheck.py index 36a3a304..c5e95906 100644 --- a/onionr/communicatorutils/netcheck.py +++ b/onionr/communicatorutils/netcheck.py @@ -22,8 +22,15 @@ import logger from utils import netutils def net_check(comm_inst): '''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 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: logger.warn('Network check failed, are you connected to the Internet, and is Tor working?') comm_inst.isOnline = False diff --git a/onionr/static-data/www/private/index.html b/onionr/static-data/www/private/index.html index 0d27d2a5..2bb74000 100644 --- a/onionr/static-data/www/private/index.html +++ b/onionr/static-data/www/private/index.html @@ -40,7 +40,7 @@

Stats

🕰️ Uptime:

-

🖇️ Last Received Connection: Unknown

+

🖇️ Last Received Connection: None since start

💾 Stored Blocks:

📨 Blocks in queue:

🔗 Outgoing Connections:

diff --git a/onionr/static-data/www/shared/main/stats.js b/onionr/static-data/www/shared/main/stats.js index 3a445acb..3c8d2af6 100644 --- a/onionr/static-data/www/shared/main/stats.js +++ b/onionr/static-data/www/shared/main/stats.js @@ -1,6 +1,5 @@ /* - - Onionr - P2P Anonymous Storage Network + Onionr - Private P2P Communication This file loads stats to show on the main node web page @@ -36,7 +35,7 @@ function getStats(){ lastConnect = humanDate.toString() } else{ - lastConnect = 'Unknown' + lastConnect = 'None since start' } lastIncoming.innerText = lastConnect }