bug fixes for tor and lock files

This commit is contained in:
Kevin Froman 2019-10-08 17:26:44 -05:00
parent c4c4fb70d5
commit 8195ffbeb6
4 changed files with 21 additions and 10 deletions

View File

@ -10,3 +10,4 @@ def delete_run_files():
_safe_remove(filepaths.public_API_host_file)
_safe_remove(filepaths.private_API_host_file)
_safe_remove(filepaths.daemon_mark_file)
_safe_remove(filepaths.lock_file)

View File

@ -128,15 +128,14 @@ HiddenServicePort 80 ''' + self.apiServerIP + ''':''' + str(self.hsPort)
tor = subprocess.Popen([self.torBinary, '-f', self.torConfigLocation], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
except FileNotFoundError:
logger.fatal("Tor was not found in your path or the Onionr directory. Please install Tor and try again.", terminal=True)
sys.exit(1)
return False
else:
# Test Tor Version
torVersion = subprocess.Popen([self.torBinary, '--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
for line in iter(torVersion.stdout.readline, b''):
if 'Tor 0.2.' in line.decode():
logger.fatal('Tor 0.3+ required', terminal=True)
sys.exit(1)
break
return False
torVersion.kill()
# wait for tor to get to 100% bootstrap
@ -147,6 +146,13 @@ HiddenServicePort 80 ''' + self.apiServerIP + ''':''' + str(self.hsPort)
break
elif 'opening socks listener' in line.decode().lower():
logger.debug(line.decode().replace('\n', ''))
else:
if 'err' in line.decode():
logger.error(line.decode().replace('\n', ''))
elif 'warn' in line.decode():
logger.warn(line.decode().replace('\n', ''))
else:
logger.debug(line.decode().replace('\n', ''))
else:
logger.fatal('Failed to start Tor. Maybe a stray instance of Tor used by Onionr is still running? This can also be a result of file permissions being too open', terminal=True)
return False
@ -213,3 +219,7 @@ HiddenServicePort 80 ''' + self.apiServerIP + ''':''' + str(self.hsPort)
os.kill(int(pidN), signal.SIGKILL)
except (ProcessLookupError, PermissionError) as e:
pass
try:
os.remove(self.dataDir + 'tordata/lock')
except FileNotFoundError:
pass

View File

@ -91,6 +91,7 @@ def daemon():
logger.info('Tor is starting...', terminal=True)
if not net.startTor():
localcommand.local_command('shutdown')
cleanup.delete_run_files()
sys.exit(1)
if len(net.myID) > 0 and config.get('general.security_level', 1) == 0:
logger.debug('Started .onion service: %s' % (logger.colors.underline + net.myID))
@ -101,7 +102,7 @@ def daemon():
try:
time.sleep(1)
except KeyboardInterrupt:
_proper_shutdown()
pass
events.event('init', threaded = False)
events.event('daemon_start')
communicator.startCommunicator(shared_state)
@ -150,10 +151,9 @@ def start(input: bool = False, override: bool = False):
lockFile.write('delete at your own risk')
lockFile.close()
daemon()
if not onionrvalues.DEVELOPMENT_MODE:
try:
os.remove(filepaths.lock_file)
except FileNotFoundError:
pass
try:
os.remove(filepaths.lock_file)
except FileNotFoundError:
pass
start.onionr_help = "Start Onionr node (public and clients API servers)"

View File

@ -116,4 +116,4 @@ def add_vanity():
key_manager.addKey(b32_pub, unpaddedbase32.b32encode(vanity[1]))
except KeyboardInterrupt:
pass
add_vanity.onionr_help = "<space separated bip32 words> - Generates and stores an Onionr vanity address (see https://github.com/trezor/python-mnemonic/blob/master/mnemonic/wordlist/english.txt)"
add_vanity.onionr_help = "<space separated words> - Generates and stores an Onionr vanity address (see https://github.com/moreati/python-niceware/blob/master/niceware/wordlist.py)"