diff --git a/README.md b/README.md index c1541186..071998f7 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ | | | | | ----------- | ----------- | ----------- | | [Install](#install-and-run-on-linux) | [Features](#main-features) | [Screenshots](#screenshots)| -| [Docs](#documentation) | [Get involved](#help-out) | [Onionr.net](https://onionr.net/)/[.onion](http://onionr.onionkvc5ibm37bmxwr56bdxcdnb6w3wm4bdghh5qo6f6za7gn7styid.onion/) | +| [Docs](#documentation)/[web copy](https://beardog108.github.io/onionr/) | [Get involved](#help-out) | [Onionr.net](https://onionr.net/)/[.onion](http://onionr.onionkvc5ibm37bmxwr56bdxcdnb6w3wm4bdghh5qo6f6za7gn7styid.onion/) |
diff --git a/docs/usage/install.md b/docs/usage/install.md index 6b2c4513..9bda7b21 100644 --- a/docs/usage/install.md +++ b/docs/usage/install.md @@ -2,12 +2,17 @@ The following steps work broadly speaking for Windows, Mac, and Linux. -1. Verify python3.7+ is installed: if its not see https://www.python.org/downloads/ +1. Verify python3.7+ is installed: if not, see https://www.python.org/downloads/ 2. Verify Tor is installed (does not need to be running, binary can be put into system path or Onionr directory) 3. [Optional but recommended]: setup virtual environment using [virtualenv](https://virtualenv.pypa.io/en/latest/), activate the virtual environment -4. Clone Onionr: git clone https://gitlab.com/beardog/onionr +4. Clone Onionr: `$ git clone https://gitlab.com/beardog/onionr` -5. Install the Python module dependencies: pip3 install --require-hashes -r requirements.txt +5. Install the Python module dependencies: `$ pip3 install --require-hashes -r requirements.txt` + + +Note: if an alternative python install is needed, use virtualenv or run Onionr commands with: + +`$ /path/to/python /path/to/onionr/onionr/__init__.py` \ No newline at end of file diff --git a/onionr/communicator/__init__.py b/onionr/communicator/__init__.py index 8cff0a9f..734bd5d7 100755 --- a/onionr/communicator/__init__.py +++ b/onionr/communicator/__init__.py @@ -19,6 +19,7 @@ along with this program. If not, see . ''' import sys, os, time + import config, logger import onionrexceptions, onionrpeers from onionrblocks import onionrblockapi as block diff --git a/onionr/etc/onionrvalues.py b/onionr/etc/onionrvalues.py index bd410532..b5cc887d 100755 --- a/onionr/etc/onionrvalues.py +++ b/onionr/etc/onionrvalues.py @@ -55,6 +55,9 @@ BLOCK_METADATA_LENGTHS = {'meta': 1000, 'sig': 200, 'signer': 200, 'time': 10, ' """Public key that signs MOTD messages shown in the web UI""" MOTD_SIGN_KEY = "TRH763JURNY47QPBTTQ4LLPYCYQK6Q5YA33R6GANKZK5C5DKCIGQ" +"""Public key that signs update notifications.""" +UPDATE_SIGN_KEY = "TRH763JURNY47QPBTTQ4LLPYCYQK6Q5YA33R6GANKZK5C5DKCIGQ" + platform = platform.system() if platform == 'Windows': SCRIPT_NAME = 'run-windows.bat' diff --git a/onionr/httpapi/miscpublicapi/upload.py b/onionr/httpapi/miscpublicapi/upload.py index fd90de32..eaf96b1a 100755 --- a/onionr/httpapi/miscpublicapi/upload.py +++ b/onionr/httpapi/miscpublicapi/upload.py @@ -46,4 +46,4 @@ def accept_upload(request): resp = Response(resp, 400) else: resp = Response(resp) - return resp \ No newline at end of file + return resp diff --git a/onionr/httpapi/onionrsitesapi/sitefiles.py b/onionr/httpapi/onionrsitesapi/sitefiles.py index 948662d3..79d66d49 100644 --- a/onionr/httpapi/onionrsitesapi/sitefiles.py +++ b/onionr/httpapi/onionrsitesapi/sitefiles.py @@ -1,3 +1,22 @@ +""" + 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 . +""" from typing import Union, Tuple import tarfile import io diff --git a/onionr/httpapi/onionrsitesapi/zsite.py b/onionr/httpapi/onionrsitesapi/zsite.py deleted file mode 100644 index aedf66bc..00000000 --- a/onionr/httpapi/onionrsitesapi/zsite.py +++ /dev/null @@ -1,4 +0,0 @@ -import zipfile -def get_zip_site_file(path): - with zipfile.ZipFile(zip_file, 'r') as zf: - for member in zf.infolist(): \ No newline at end of file diff --git a/onionr/onionrblocks/insert.py b/onionr/onionrblocks/insert.py index 301d5a49..cb9e050c 100644 --- a/onionr/onionrblocks/insert.py +++ b/onionr/onionrblocks/insert.py @@ -1,5 +1,25 @@ +""" + Onionr - Private P2P Communication + + Create and insert Onionr blocks +""" +""" + 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 . +""" from typing import Union import json + from onionrutils import bytesconverter, epoch import filepaths, onionrstorage from . import storagecounter diff --git a/onionr/onionrcommands/restartonionr.py b/onionr/onionrcommands/restartonionr.py index c7bdab7d..3514896c 100644 --- a/onionr/onionrcommands/restartonionr.py +++ b/onionr/onionrcommands/restartonionr.py @@ -23,6 +23,7 @@ import subprocess import platform from etc import onionrvalues +from etc import cleanup from onionrutils import localcommand import logger import filepaths @@ -38,7 +39,9 @@ def restart(): try: pid = os.fork() if pid != 0: return - except (AttributeError, OSError) as e: pass + except (AttributeError, OSError) as e: + if platform.platform() != 'Windows': + logger.warn('Could not fork on restart') daemonlaunch.kill_daemon() while localcommand.local_command('ping', maxWait=8) == 'pong!': @@ -46,6 +49,8 @@ def restart(): time.sleep(15) while os.path.exists(filepaths.private_API_host_file) or os.path.exists(filepaths.daemon_mark_file): time.sleep(1) + + cleanup.delete_run_files() subprocess.Popen([SCRIPT_NAME, 'start']) restart.onionr_help = 'Gracefully restart Onionr' diff --git a/onionr/onionrexceptions.py b/onionr/onionrexceptions.py index 336e7c9f..ddb19d82 100755 --- a/onionr/onionrexceptions.py +++ b/onionr/onionrexceptions.py @@ -51,6 +51,9 @@ class SignatureError(Exception): class ReplayAttack(Exception): pass +class InvalidUpdate(Exception): + pass + class DifficultyTooLarge(Exception): pass diff --git a/onionr/onionrtypes/__init__.py b/onionr/onionrtypes/__init__.py index f64a33f5..88955237 100644 --- a/onionr/onionrtypes/__init__.py +++ b/onionr/onionrtypes/__init__.py @@ -5,4 +5,6 @@ UserIDSecretKey = NewType('UserIDSecretKey', str) DeterministicKeyPassphrase = NewType('DeterministicKeyPassphrase', str) -BlockHash = NewType('BlockHash', str) \ No newline at end of file +BlockHash = NewType('BlockHash', str) + +RestartRequiredStatus = NewType('RestartRequiredStatus', bool) diff --git a/onionr/onionrutils/blockmetadata/process.py b/onionr/onionrutils/blockmetadata/process.py index dda19d85..a144e5b9 100644 --- a/onionr/onionrutils/blockmetadata/process.py +++ b/onionr/onionrutils/blockmetadata/process.py @@ -26,6 +26,7 @@ import logger from onionrplugins import onionrevents import onionrexceptions from onionrusers import onionrusers +from onionrutils import updater def process_block_metadata(blockHash: str): ''' @@ -67,4 +68,5 @@ def process_block_metadata(blockHash: str): expireTime = min(expireTime, curTime + onionrvalues.DEFAULT_EXPIRE) blockmetadb.update_block_info(blockHash, 'expire', expireTime) + if blockType == 'update': updater.update_event(myBlock) onionrevents.event('processblocks', data = {'block': myBlock, 'type': blockType, 'signer': signer, 'validSig': valid}) diff --git a/onionr/onionrutils/updater/__init__.py b/onionr/onionrutils/updater/__init__.py new file mode 100644 index 00000000..bbbc730d --- /dev/null +++ b/onionr/onionrutils/updater/__init__.py @@ -0,0 +1,29 @@ +""" + Onionr - Private P2P Communication + + Lib to keep Onionr up to date +""" +""" + 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 . +""" +from onionrtypes import RestartRequiredStatus +from onionrblocks.onionrblockapi import Block +from etc import onionrvalues +import onionrexceptions +import notifier + +def update_event(bl: Block)->RestartRequiredStatus: + """Show update notification if available, return bool of if update happend""" + if not bl.isSigner(onionrvalues.UPDATE_SIGN_KEY): raise onionrexceptions.InvalidUpdate + notifier.notify(message="A new Onionr update is available. Stay updated to remain secure.") diff --git a/static-data/default_config.json b/static-data/default_config.json index 8f3d97e6..d8ff8e7e 100755 --- a/static-data/default_config.json +++ b/static-data/default_config.json @@ -1,6 +1,6 @@ { "general": { - "dev_mode": true, + "dev_mode": false, "announce_node": true, "display_header": false, "minimum_block_pow": 4, @@ -18,6 +18,11 @@ "show_notifications": true }, + "transports": { + "tor": true, + "manual_disk": true + }, + "ui": { "theme": "dark" },