From 982ac88a72f55460114c933e281a01ccdc8157a8 Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Sat, 8 Feb 2020 04:24:19 -0600 Subject: [PATCH] print tor startup progress to term --- src/etc/onionrvalues.py | 2 +- src/netcontroller/torcontrol/__init__.py | 12 +++++++++--- src/utils/__init__.py | 1 + src/utils/boxprint.py | 8 ++++++++ 4 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 src/utils/boxprint.py diff --git a/src/etc/onionrvalues.py b/src/etc/onionrvalues.py index 26f08951..10a90307 100755 --- a/src/etc/onionrvalues.py +++ b/src/etc/onionrvalues.py @@ -23,7 +23,7 @@ import filepaths DENIABLE_PEER_ADDRESS = "OVPCZLOXD6DC5JHX4EQ3PSOGAZ3T24F75HQLIUZSDSMYPEOXCPFA" PASSWORD_LENGTH = 25 ONIONR_TAGLINE = 'Private P2P Communication - GPLv3 - https://Onionr.net' -ONIONR_VERSION = '3.0.0' +ONIONR_VERSION = '3.1.0' ONIONR_VERSION_CODENAME = 'Genesis' ONIONR_VERSION_TUPLE = tuple(ONIONR_VERSION.split('.')) # (MAJOR, MINOR, VERSION) API_VERSION = '1' # increments of 1; only change when something fundamental about how the API works changes. This way other nodes know how to communicate without learning too much information about you. diff --git a/src/netcontroller/torcontrol/__init__.py b/src/netcontroller/torcontrol/__init__.py index 6fca8809..2a31bc92 100644 --- a/src/netcontroller/torcontrol/__init__.py +++ b/src/netcontroller/torcontrol/__init__.py @@ -21,6 +21,7 @@ from . import gentorrc from . import addbridges from . import torbinary from utils import identifyhome +from utils import box_print """ This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -41,9 +42,7 @@ addbridges = addbridges.add_bridges class NetController: - """ - This class handles hidden service setup on Tor - """ + """Handle Tor daemon and onion service setup on Tor.""" def __init__(self, hsPort, apiServerIP='127.0.0.1'): # set data dir @@ -90,6 +89,12 @@ class NetController: # wait for tor to get to 100% bootstrap try: for line in iter(tor.stdout.readline, b''): + for word in ('bootstrapped', '%'): + if word not in line.decode().lower(): + break + else: + if '100' not in line.decode(): + logger.info(line.decode().strip(), terminal=True) if 'bootstrapped 100' in line.decode().lower(): logger.info(line.decode()) break @@ -110,6 +115,7 @@ class NetController: return False logger.info('Finished starting Tor.', terminal=True) + logger.info('Connecting to Onionr soon', terminal=True) self.readyState = True diff --git a/src/utils/__init__.py b/src/utils/__init__.py index e69de29b..359a6c24 100644 --- a/src/utils/__init__.py +++ b/src/utils/__init__.py @@ -0,0 +1 @@ +from .boxprint import bordered as box_print \ No newline at end of file diff --git a/src/utils/boxprint.py b/src/utils/boxprint.py new file mode 100644 index 00000000..9f37426e --- /dev/null +++ b/src/utils/boxprint.py @@ -0,0 +1,8 @@ +def bordered(text): + lines = text.splitlines() + width = max(len(s) for s in lines) + res = ['┌' + '─' * width + '┐'] + for s in lines: + res.append('│' + (s + ' ' * width)[:width] + '│') + res.append('└' + '─' * width + '┘') + return '\n'.join(res) \ No newline at end of file