From 9f61a933979a1e8274d912d40a8a14f1f3b3e17f Mon Sep 17 00:00:00 2001 From: 0Gitnick Date: Tue, 14 Apr 2020 22:52:50 -0500 Subject: [PATCH 1/5] Add hash to requirements.txt --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 8dcaaf28..5925e526 100644 --- a/requirements.txt +++ b/requirements.txt @@ -205,6 +205,7 @@ stem==1.8.0 \ # via -r requirements.in streamedrequests==1.0.0 \ --hash=sha256:1d9d07394804a6e1fd66bde74a804e71cab98e6920053865574a459f1cf7d3b7 \ + --hash=sha256:c7c22fa89898619fb4ccba0c60df1ad5e581bc707794ee146d8ef72ab3216a50 \ # via -r requirements.in toomanyobjs==1.1.0 \ --hash=sha256:99e27468f9dad19127be9e2fb086b42acd69aed9ad7e63cef74d6e4389be0534 \ From 33896d9c91a7d5e5fe3bdb0f301a3ce018faaed4 Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Tue, 9 Jun 2020 21:08:34 -0500 Subject: [PATCH 2/5] remove block count in readme --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index ac15a97f..67092a7e 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,6 @@ -current stored block count - | | | | From 2a65f605f59d471c522dfa5223062a940898b6e4 Mon Sep 17 00:00:00 2001 From: Kevin Date: Sat, 13 Jun 2020 17:49:16 -0500 Subject: [PATCH 3/5] fix site creator not working with full paths by using a temporary chdir fix grammar issue in site creator --- src/onionrcommands/sitecreator.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/onionrcommands/sitecreator.py b/src/onionrcommands/sitecreator.py index b0d14ed0..e0d6360b 100644 --- a/src/onionrcommands/sitecreator.py +++ b/src/onionrcommands/sitecreator.py @@ -3,6 +3,7 @@ Command to create Onionr mutli-page sites """ import sys +import os import getpass from httpapi import onionrsitesapi @@ -27,8 +28,11 @@ from etc import onionrvalues def create_multipage_site(): """Command to create mutlipage sites with specified dir and password.""" error_encountered = False + orig_dir = os.getcwd() try: directory = sys.argv[2] + os.chdir(directory) + directory = '.' except IndexError: directory = '.' try: @@ -51,7 +55,7 @@ If you want to update your site later you must remember the passphrase.''', error_encountered = True logger.error( f'Passphrase must be at least {onionrvalues.PASSWORD_LENGTH}' + - 'characters.', terminal=True) + ' characters.', terminal=True) if error_encountered: sys.exit(1) @@ -61,6 +65,7 @@ If you want to update your site later you must remember the passphrase.''', results = (results[0].replace('=', ''), results[1]) logger.info(f'Site address {results[0]}', terminal=True) logger.info(f'Block for this version {results[1]}', terminal=True) + os.chdir(orig_dir) create_multipage_site.onionr_help = "[directory path " # type: ignore From 3d0f1d93370802e24d41f3f916ca1c42a1213521 Mon Sep 17 00:00:00 2001 From: Kevin Date: Sat, 13 Jun 2020 17:50:37 -0500 Subject: [PATCH 4/5] fix import format in sitecreator init --- src/httpapi/onionrsitesapi/__init__.py | 34 +++++++++++++------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/httpapi/onionrsitesapi/__init__.py b/src/httpapi/onionrsitesapi/__init__.py index f369c475..a00fb39d 100644 --- a/src/httpapi/onionrsitesapi/__init__.py +++ b/src/httpapi/onionrsitesapi/__init__.py @@ -1,21 +1,6 @@ -""" - Onionr - Private P2P Communication +"""Onionr - Private P2P Communication. - view and interact with onionr sites -""" -""" - 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 - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . +view and interact with onionr sites """ import base64 import binascii @@ -31,6 +16,21 @@ from onionrutils import stringvalidators from utils import safezip from onionrutils import mnemonickeys from . import sitefiles +""" + 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 + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +""" + site_api = Blueprint('siteapi', __name__) From a401f49da3f5b79c9817c70c4891f9ce911c37f5 Mon Sep 17 00:00:00 2001 From: Kevin Date: Sat, 13 Jun 2020 17:51:09 -0500 Subject: [PATCH 5/5] fix index.html not being auto loaded in subdirs fix pep8 styling in sitefiles.py --- src/httpapi/onionrsitesapi/sitefiles.py | 43 ++++++++++++++----------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/src/httpapi/onionrsitesapi/sitefiles.py b/src/httpapi/onionrsitesapi/sitefiles.py index 79d66d49..f9171926 100644 --- a/src/httpapi/onionrsitesapi/sitefiles.py +++ b/src/httpapi/onionrsitesapi/sitefiles.py @@ -1,21 +1,6 @@ -""" - Onionr - Private P2P Communication +"""Onionr - Private P2P Communication. - Read onionr site files -""" -""" - 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 - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . +Read onionr site files """ from typing import Union, Tuple import tarfile @@ -32,30 +17,52 @@ from onionrblocks import insert from onionrtypes import UserID, DeterministicKeyPassphrase, BlockHash from onionrcrypto import generate_deterministic +""" + 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 + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +""" + def find_site_gzip(user_id: str)->tarfile.TarFile: """Return verified site tar object""" sites = blockmetadb.get_blocks_by_type('osite') user_site = None + unpadded_user = user_id user_id = unpaddedbase32.repad(user_id) for site in sites: block = onionrblockapi.Block(site) - if block.isSigner(user_id): + if block.isSigner(user_id) or block.isSigner(unpadded_user): user_site = block if not user_site is None: return tarfile.open(fileobj=io.BytesIO(user_site.bcontent), mode='r') return None + def get_file(user_id, file)->Union[bytes, None]: """Get a site file content""" ret_data = "" site = find_site_gzip(user_id) + + if file.endswith('/'): + file += 'index.html' if site is None: return None for t_file in site.getmembers(): + if t_file.name.replace('./', '') == file: return site.extractfile(t_file) return None + def create_site(admin_pass: DeterministicKeyPassphrase, directory:str='.')->Tuple[UserID, BlockHash]: public_key, private_key = generate_deterministic(admin_pass)