From 00e2445475bb543b20d5bcc941b137177b5f1268 Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Sun, 11 Aug 2019 13:53:38 -0500 Subject: [PATCH] make tor restart more aggressive as last resort for tor-death bug --- onionr/communicatorutils/daemonqueuehandler.py | 2 +- onionr/netcontroller/netcontrol.py | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/onionr/communicatorutils/daemonqueuehandler.py b/onionr/communicatorutils/daemonqueuehandler.py index 924d4ebf..007b8603 100755 --- a/onionr/communicatorutils/daemonqueuehandler.py +++ b/onionr/communicatorutils/daemonqueuehandler.py @@ -61,4 +61,4 @@ def handle_daemon_commands(comm_inst): localcommand.local_command('queueResponseAdd/' + cmd[4], post=True, postData={'data': response}) response = '' - comm_inst.decrementThreadCount('handle_daemon_commands') \ No newline at end of file + comm_inst.decrementThreadCount('handle_daemon_commands') diff --git a/onionr/netcontroller/netcontrol.py b/onionr/netcontroller/netcontrol.py index 3732e68c..cf3fa41b 100644 --- a/onionr/netcontroller/netcontrol.py +++ b/onionr/netcontroller/netcontrol.py @@ -17,11 +17,12 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . ''' -import os, sys, base64, subprocess, signal +import os, sys, base64, subprocess, signal, time import config, logger from . import getopenport from utils import identifyhome config.reload() +TOR_KILL_WAIT = 3 class NetController: ''' This class handles hidden service setup on Tor and I2P @@ -179,5 +180,8 @@ HiddenServicePort 80 ''' + self.apiServerIP + ''':''' + str(self.hsPort) pass except FileNotFoundError: pass - - return + time.sleep(TOR_KILL_WAIT) + try: + os.kill(int(pidN), signal.SIGKILL) + except (ProcessLookupError, PermissionError) as e: + pass