bug fixes for tor and lock files
parent
c4c4fb70d5
commit
8195ffbeb6
|
@ -10,3 +10,4 @@ def delete_run_files():
|
||||||
_safe_remove(filepaths.public_API_host_file)
|
_safe_remove(filepaths.public_API_host_file)
|
||||||
_safe_remove(filepaths.private_API_host_file)
|
_safe_remove(filepaths.private_API_host_file)
|
||||||
_safe_remove(filepaths.daemon_mark_file)
|
_safe_remove(filepaths.daemon_mark_file)
|
||||||
|
_safe_remove(filepaths.lock_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)
|
tor = subprocess.Popen([self.torBinary, '-f', self.torConfigLocation], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
logger.fatal("Tor was not found in your path or the Onionr directory. Please install Tor and try again.", terminal=True)
|
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:
|
else:
|
||||||
# Test Tor Version
|
# Test Tor Version
|
||||||
torVersion = subprocess.Popen([self.torBinary, '--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
torVersion = subprocess.Popen([self.torBinary, '--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
for line in iter(torVersion.stdout.readline, b''):
|
for line in iter(torVersion.stdout.readline, b''):
|
||||||
if 'Tor 0.2.' in line.decode():
|
if 'Tor 0.2.' in line.decode():
|
||||||
logger.fatal('Tor 0.3+ required', terminal=True)
|
logger.fatal('Tor 0.3+ required', terminal=True)
|
||||||
sys.exit(1)
|
return False
|
||||||
break
|
|
||||||
torVersion.kill()
|
torVersion.kill()
|
||||||
|
|
||||||
# wait for tor to get to 100% bootstrap
|
# wait for tor to get to 100% bootstrap
|
||||||
|
@ -147,6 +146,13 @@ HiddenServicePort 80 ''' + self.apiServerIP + ''':''' + str(self.hsPort)
|
||||||
break
|
break
|
||||||
elif 'opening socks listener' in line.decode().lower():
|
elif 'opening socks listener' in line.decode().lower():
|
||||||
logger.debug(line.decode().replace('\n', ''))
|
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:
|
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)
|
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
|
return False
|
||||||
|
@ -213,3 +219,7 @@ HiddenServicePort 80 ''' + self.apiServerIP + ''':''' + str(self.hsPort)
|
||||||
os.kill(int(pidN), signal.SIGKILL)
|
os.kill(int(pidN), signal.SIGKILL)
|
||||||
except (ProcessLookupError, PermissionError) as e:
|
except (ProcessLookupError, PermissionError) as e:
|
||||||
pass
|
pass
|
||||||
|
try:
|
||||||
|
os.remove(self.dataDir + 'tordata/lock')
|
||||||
|
except FileNotFoundError:
|
||||||
|
pass
|
||||||
|
|
|
@ -91,6 +91,7 @@ def daemon():
|
||||||
logger.info('Tor is starting...', terminal=True)
|
logger.info('Tor is starting...', terminal=True)
|
||||||
if not net.startTor():
|
if not net.startTor():
|
||||||
localcommand.local_command('shutdown')
|
localcommand.local_command('shutdown')
|
||||||
|
cleanup.delete_run_files()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
if len(net.myID) > 0 and config.get('general.security_level', 1) == 0:
|
if len(net.myID) > 0 and config.get('general.security_level', 1) == 0:
|
||||||
logger.debug('Started .onion service: %s' % (logger.colors.underline + net.myID))
|
logger.debug('Started .onion service: %s' % (logger.colors.underline + net.myID))
|
||||||
|
@ -101,7 +102,7 @@ def daemon():
|
||||||
try:
|
try:
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
_proper_shutdown()
|
pass
|
||||||
events.event('init', threaded = False)
|
events.event('init', threaded = False)
|
||||||
events.event('daemon_start')
|
events.event('daemon_start')
|
||||||
communicator.startCommunicator(shared_state)
|
communicator.startCommunicator(shared_state)
|
||||||
|
@ -150,7 +151,6 @@ def start(input: bool = False, override: bool = False):
|
||||||
lockFile.write('delete at your own risk')
|
lockFile.write('delete at your own risk')
|
||||||
lockFile.close()
|
lockFile.close()
|
||||||
daemon()
|
daemon()
|
||||||
if not onionrvalues.DEVELOPMENT_MODE:
|
|
||||||
try:
|
try:
|
||||||
os.remove(filepaths.lock_file)
|
os.remove(filepaths.lock_file)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
|
|
|
@ -116,4 +116,4 @@ def add_vanity():
|
||||||
key_manager.addKey(b32_pub, unpaddedbase32.b32encode(vanity[1]))
|
key_manager.addKey(b32_pub, unpaddedbase32.b32encode(vanity[1]))
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
pass
|
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)"
|
||||||
|
|
Loading…
Reference in New Issue