boiler plate and bug fixes

master
Kevin Froman 2019-11-15 22:18:38 -06:00
parent 15b3d506ff
commit 6cc01fa240
14 changed files with 102 additions and 12 deletions

View File

@ -17,7 +17,7 @@
| | | | | | | |
| ----------- | ----------- | ----------- | | ----------- | ----------- | ----------- |
| [Install](#install-and-run-on-linux) | [Features](#main-features) | [Screenshots](#screenshots)| | [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/) |
<hr> <hr>

View File

@ -2,12 +2,17 @@
The following steps work broadly speaking for Windows, Mac, and Linux. 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) 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 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`

View File

@ -19,6 +19,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. along with this program. If not, see <https://www.gnu.org/licenses/>.
''' '''
import sys, os, time import sys, os, time
import config, logger import config, logger
import onionrexceptions, onionrpeers import onionrexceptions, onionrpeers
from onionrblocks import onionrblockapi as block from onionrblocks import onionrblockapi as block

View File

@ -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""" """Public key that signs MOTD messages shown in the web UI"""
MOTD_SIGN_KEY = "TRH763JURNY47QPBTTQ4LLPYCYQK6Q5YA33R6GANKZK5C5DKCIGQ" MOTD_SIGN_KEY = "TRH763JURNY47QPBTTQ4LLPYCYQK6Q5YA33R6GANKZK5C5DKCIGQ"
"""Public key that signs update notifications."""
UPDATE_SIGN_KEY = "TRH763JURNY47QPBTTQ4LLPYCYQK6Q5YA33R6GANKZK5C5DKCIGQ"
platform = platform.system() platform = platform.system()
if platform == 'Windows': if platform == 'Windows':
SCRIPT_NAME = 'run-windows.bat' SCRIPT_NAME = 'run-windows.bat'

View File

@ -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 <https://www.gnu.org/licenses/>.
"""
from typing import Union, Tuple from typing import Union, Tuple
import tarfile import tarfile
import io import io

View File

@ -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():

View File

@ -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 <https://www.gnu.org/licenses/>.
"""
from typing import Union from typing import Union
import json import json
from onionrutils import bytesconverter, epoch from onionrutils import bytesconverter, epoch
import filepaths, onionrstorage import filepaths, onionrstorage
from . import storagecounter from . import storagecounter

View File

@ -23,6 +23,7 @@ import subprocess
import platform import platform
from etc import onionrvalues from etc import onionrvalues
from etc import cleanup
from onionrutils import localcommand from onionrutils import localcommand
import logger import logger
import filepaths import filepaths
@ -38,7 +39,9 @@ def restart():
try: try:
pid = os.fork() pid = os.fork()
if pid != 0: return 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() daemonlaunch.kill_daemon()
while localcommand.local_command('ping', maxWait=8) == 'pong!': while localcommand.local_command('ping', maxWait=8) == 'pong!':
@ -46,6 +49,8 @@ def restart():
time.sleep(15) time.sleep(15)
while os.path.exists(filepaths.private_API_host_file) or os.path.exists(filepaths.daemon_mark_file): while os.path.exists(filepaths.private_API_host_file) or os.path.exists(filepaths.daemon_mark_file):
time.sleep(1) time.sleep(1)
cleanup.delete_run_files()
subprocess.Popen([SCRIPT_NAME, 'start']) subprocess.Popen([SCRIPT_NAME, 'start'])
restart.onionr_help = 'Gracefully restart Onionr' restart.onionr_help = 'Gracefully restart Onionr'

View File

@ -51,6 +51,9 @@ class SignatureError(Exception):
class ReplayAttack(Exception): class ReplayAttack(Exception):
pass pass
class InvalidUpdate(Exception):
pass
class DifficultyTooLarge(Exception): class DifficultyTooLarge(Exception):
pass pass

View File

@ -6,3 +6,5 @@ UserIDSecretKey = NewType('UserIDSecretKey', str)
DeterministicKeyPassphrase = NewType('DeterministicKeyPassphrase', str) DeterministicKeyPassphrase = NewType('DeterministicKeyPassphrase', str)
BlockHash = NewType('BlockHash', str) BlockHash = NewType('BlockHash', str)
RestartRequiredStatus = NewType('RestartRequiredStatus', bool)

View File

@ -26,6 +26,7 @@ import logger
from onionrplugins import onionrevents from onionrplugins import onionrevents
import onionrexceptions import onionrexceptions
from onionrusers import onionrusers from onionrusers import onionrusers
from onionrutils import updater
def process_block_metadata(blockHash: str): def process_block_metadata(blockHash: str):
''' '''
@ -67,4 +68,5 @@ def process_block_metadata(blockHash: str):
expireTime = min(expireTime, curTime + onionrvalues.DEFAULT_EXPIRE) expireTime = min(expireTime, curTime + onionrvalues.DEFAULT_EXPIRE)
blockmetadb.update_block_info(blockHash, 'expire', expireTime) 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}) onionrevents.event('processblocks', data = {'block': myBlock, 'type': blockType, 'signer': signer, 'validSig': valid})

View File

@ -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 <https://www.gnu.org/licenses/>.
"""
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.")

View File

@ -1,6 +1,6 @@
{ {
"general": { "general": {
"dev_mode": true, "dev_mode": false,
"announce_node": true, "announce_node": true,
"display_header": false, "display_header": false,
"minimum_block_pow": 4, "minimum_block_pow": 4,
@ -18,6 +18,11 @@
"show_notifications": true "show_notifications": true
}, },
"transports": {
"tor": true,
"manual_disk": true
},
"ui": { "ui": {
"theme": "dark" "theme": "dark"
}, },