From aab150c866693081611d4b595472f27440272144 Mon Sep 17 00:00:00 2001 From: ralphwetzel Date: Sun, 29 Dec 2019 23:35:24 +0100 Subject: [PATCH] 19.3 (#71) * Fix to prevent setup.py from import theonionbox; addressing PEP#517. * Housekeeping: Removed some artefacts. * Dashboard: Session 'prepared' after successful login was not accepted as valid. Fixed. * Dashboard: Truncate __HashedControlSessionPassword (alike HashedControlPassword). No need to show this in full length. * 19.3 --- setup.py | 24 ++++++++++++++++++------ theonionbox/__main__.py | 2 +- theonionbox/sections/config/config.html | 8 ++++---- theonionbox/stamp.py | 4 ++-- theonionbox/theonionbox.py | 4 ++-- theonionbox/tob/apps/dashboard.py | 2 ++ 6 files changed, 29 insertions(+), 15 deletions(-) diff --git a/setup.py b/setup.py index f73fe8c..a54ac86 100644 --- a/setup.py +++ b/setup.py @@ -5,10 +5,22 @@ import setuptools.command.build_ext import setuptools.command.sdist import setuptools.command.install -import theonionbox.stamp as stamp from distutils.extension import Extension +# This code replaces ... +# import theonionbox.stamp as stamp +# used here up to TOB 19.2 +# but failing meanwhile with pip > 18 due to PEP#517 trouble +# ref: https://github.com/pypa/pip/issues/6163 +# ref: https://packaging.python.org/guides/single-sourcing-package-version/: + +stamp = {} +with open("theonionbox/stamp.py") as fp: + exec(fp.read(), stamp) + +# later on we use: stamp['__version__'] + # Custom command to compile the latest README.html # BTW: grip is quite cool! def CompileREADME(): @@ -72,7 +84,7 @@ def file_as_blockiter(afile, blocksize=65536): if (old_md_hash != current_md_hash) or (old_html_hash != current_html_hash): from grip import export - export(path='README.md', out_filename='readme/README.html', title=f'{stamp.__title__} v{stamp.__version__}') + export(path='README.md', out_filename='readme/README.html', title=f"{stamp['__title__']} v{stamp['__version__']}") hash_changed = True else: print('Skiping generation of README.html; files unchanged!') @@ -302,11 +314,11 @@ def generate_data_files(data_files): package_data_exclude = { 'theonionbox': ['sections/controlcenter/*', - 'sections/cc/*', ] } data_files = [ + # ('', ['pyproject.toml']), ('docs', ['docs/*.*']), ('', ['readme/README.html']), ('config', ['theonionbox/config/*.*']), @@ -368,7 +380,7 @@ def generate_data_files(data_files): cmdclass={'sdist': sdist, }, name='theonionbox', - version=stamp.__version__, + version=stamp['__version__'], # py_modules=['theonionbox.py'], packages=packages, package_dir=package_dir, @@ -381,7 +393,7 @@ def generate_data_files(data_files): license='MIT', author='Ralph Wetzel', author_email='theonionbox@gmx.com', - description=f'{stamp.__title__}: {stamp.__description__}', + description=f"{stamp['__title__']}: {stamp['__description__']}", long_description=open('docs/description.rst', 'rb').read().decode('utf-8'), entry_points={ 'console_scripts': [ @@ -394,7 +406,7 @@ def generate_data_files(data_files): 'requests>=2.21', 'PySocks>=1.6.7', 'bottle>=0.12.16', - 'stem>=1.7.0', + 'stem4tob>=1.7.1.post3', 'tzlocal>=1.5', # 'futures>=3.2; python_version<"3.0"', 'urllib3>=1.22', diff --git a/theonionbox/__main__.py b/theonionbox/__main__.py index ab73a03..cf50a7c 100644 --- a/theonionbox/__main__.py +++ b/theonionbox/__main__.py @@ -23,7 +23,7 @@ def main(): if __name__ == '__main__': - args = sys.argv[1:] + # args = sys.argv[1:] main() diff --git a/theonionbox/sections/config/config.html b/theonionbox/sections/config/config.html index de398a2..938d87e 100644 --- a/theonionbox/sections/config/config.html +++ b/theonionbox/sections/config/config.html @@ -86,12 +86,12 @@ if len(out): out += ' ' end - if hcp == 1 and cmd[:3] == '16:': + if (hcp % 2 > 0) and cmd[:3] == '16:': cmd = cmd[:12] + '...' # no need to transmit this completely! hcp += 1 end - if cmd == "HashedControlPassword": - hcp = 1 + if "HashedControlPassword" in cmd or "HashedControlSessionPassword" in cmd: + hcp += 1 end out += cmd end @@ -99,7 +99,7 @@ {{out}} % if hcp > 1:
- The HashedControlPassword was truncated for safety reasons. + The HashedControl(Session)Password was truncated for safety reasons.
% end diff --git a/theonionbox/stamp.py b/theonionbox/stamp.py index f9eb659..fd5f792 100644 --- a/theonionbox/stamp.py +++ b/theonionbox/stamp.py @@ -1,4 +1,4 @@ __title__ = 'The Onion Box' __description__ = 'Dashboard to monitor Tor node operations.' -__version__ = '19.2' -__stamp__ = '20191202|224123' +__version__ = '19.3' +__stamp__ = '20191229|232641' \ No newline at end of file diff --git a/theonionbox/theonionbox.py b/theonionbox/theonionbox.py index 5a0e603..2739f04 100644 --- a/theonionbox/theonionbox.py +++ b/theonionbox/theonionbox.py @@ -312,8 +312,8 @@ def proxy(ctx, control, host, port, socket, proxy): }} -if __name__ == '__main__': +# if __name__ == '__main__': # main(box_debug) - main() +# main() # __all__ = ['main'] diff --git a/theonionbox/tob/apps/dashboard.py b/theonionbox/tob/apps/dashboard.py index d0f9075..2abf4dc 100644 --- a/theonionbox/tob/apps/dashboard.py +++ b/theonionbox/tob/apps/dashboard.py @@ -98,6 +98,8 @@ def __init__(self callback=self.get_logout, **config) + config['valid_status'] = ['ok', 'auto', 'prepared'] + self.app.route('//index.html', method='GET', callback=self.get_index,