improved network stability by having automatic tor restarts
This commit is contained in:
parent
daff149acc
commit
75ec108496
11 changed files with 48 additions and 16 deletions
|
@ -22,6 +22,7 @@ import onionrevents as events
|
|||
from onionrutils import localcommand
|
||||
from coredb import daemonqueue
|
||||
import filepaths
|
||||
from . import restarttor
|
||||
def handle_daemon_commands(comm_inst):
|
||||
cmd = daemonqueue.daemon_queue()
|
||||
response = ''
|
||||
|
@ -43,6 +44,11 @@ def handle_daemon_commands(comm_inst):
|
|||
response = 'none'
|
||||
elif cmd[0] == 'localCommand':
|
||||
response = localcommand.local_command(cmd[1])
|
||||
elif cmd[0] == 'clearOffline':
|
||||
comm_inst.offlinePeers = []
|
||||
elif cmd[0] == 'restartTor':
|
||||
restarttor.restart(comm_inst)
|
||||
comm_inst.offlinePeers = []
|
||||
elif cmd[0] == 'pex':
|
||||
for i in comm_inst.timers:
|
||||
if i.timerFunction.__name__ == 'lookupAdders':
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
import logger
|
||||
from utils import netutils
|
||||
from onionrutils import localcommand, epoch
|
||||
from . import restarttor
|
||||
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
|
||||
|
@ -33,7 +34,9 @@ def net_check(comm_inst):
|
|||
pass
|
||||
if not rec and not netutils.checkNetwork(torPort=comm_inst.proxyPort):
|
||||
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?', terminal=True)
|
||||
restarttor.restart(comm_inst)
|
||||
comm_inst.offlinePeers = []
|
||||
comm_inst.isOnline = False
|
||||
else:
|
||||
comm_inst.isOnline = True
|
||||
|
|
5
onionr/communicatorutils/restarttor.py
Normal file
5
onionr/communicatorutils/restarttor.py
Normal file
|
@ -0,0 +1,5 @@
|
|||
import netcontroller
|
||||
def restart(comm_inst):
|
||||
net = comm_inst.shared_state.get(netcontroller.NetController)
|
||||
net.killTor()
|
||||
net.startTor()
|
Loading…
Add table
Add a link
Reference in a new issue