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)|
| [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>

View File

@ -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`

View File

@ -19,6 +19,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
'''
import sys, os, time
import config, logger
import onionrexceptions, onionrpeers
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"""
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'

View File

@ -46,4 +46,4 @@ def accept_upload(request):
resp = Response(resp, 400)
else:
resp = Response(resp)
return resp
return resp

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
import tarfile
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
import json
from onionrutils import bytesconverter, epoch
import filepaths, onionrstorage
from . import storagecounter

View File

@ -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'

View File

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

View File

@ -5,4 +5,6 @@ UserIDSecretKey = NewType('UserIDSecretKey', 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
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})

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": {
"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"
},