netcheck now also uses last incomming connection time
This commit is contained in:
parent
c4fa0c15f0
commit
faa79bb35c
3 changed files with 11 additions and 5 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue