renamed onionr dir and bugfixes/linting progress
This commit is contained in:
parent
2b996da17f
commit
720efe4fca
42
.gitignore
vendored
42
.gitignore
vendored
@ -1,25 +1,22 @@
|
||||
__pycache__/
|
||||
onionr/data/config.ini
|
||||
onionr/data/*.db
|
||||
onionr/data-old/*
|
||||
onionr/data*
|
||||
onionr/tor
|
||||
onionr/tor.exe
|
||||
onionr/testdata
|
||||
onionr/*.pyc
|
||||
onionr/*.log
|
||||
onionr/data/hs/hostname
|
||||
onionr/data/*
|
||||
onionr/data-backup/*
|
||||
onionr/gnupg/*
|
||||
src/data/config.ini
|
||||
src/data/*.db
|
||||
src/data-old/*
|
||||
src/data*
|
||||
src/tor
|
||||
src/tor.exe
|
||||
src/testdata
|
||||
src/*.pyc
|
||||
src/*.log
|
||||
src/data/hs/hostname
|
||||
src/data/*
|
||||
src/data-backup/*
|
||||
run.sh
|
||||
onionr/data-encrypted.dat
|
||||
onionr/.onionr-lock
|
||||
core
|
||||
src/.onionr-lock
|
||||
.vscode/*
|
||||
venv/*
|
||||
onionr/fs*
|
||||
onionr/tmp/*
|
||||
src/fs*
|
||||
src/tmp/*
|
||||
testdata/*
|
||||
*.dll
|
||||
*.exe
|
||||
@ -29,13 +26,12 @@ dist/*
|
||||
# log files
|
||||
output.log
|
||||
*.log
|
||||
onionr/output.log
|
||||
onionr/*.log
|
||||
onionr/data/output.log
|
||||
onionr/data/*.log
|
||||
src/output.log
|
||||
src/*.log
|
||||
src/data/output.log
|
||||
src/data/*.log
|
||||
|
||||
# package files
|
||||
onionr-*.pkg.tar.gz
|
||||
pkg/
|
||||
src/
|
||||
spawnnodes.py
|
||||
|
@ -2,7 +2,7 @@
|
||||
rm -rf dist
|
||||
mkdir dist
|
||||
mkdir dist/onionr/
|
||||
cp -t dist/onionr/ -r docs static-data install onionr onionr.sh start-daemon.sh setprofile.sh
|
||||
cp -t dist/onionr/ -r docs static-data install src onionr.sh start-daemon.sh setprofile.sh
|
||||
cp *.md dist/onionr/
|
||||
PIP_USER=false
|
||||
export PIP_USER
|
||||
|
@ -2,5 +2,5 @@
|
||||
ORIG_ONIONR_RUN_DIR=`pwd`
|
||||
export ORIG_ONIONR_RUN_DIR
|
||||
cd "$(dirname "$0")"
|
||||
cd onionr
|
||||
cd src
|
||||
./__init__.py "$@"
|
@ -1,13 +0,0 @@
|
||||
import os, filepaths
|
||||
|
||||
def _safe_remove(path):
|
||||
try:
|
||||
os.remove(path)
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
|
||||
def delete_run_files():
|
||||
_safe_remove(filepaths.public_API_host_file)
|
||||
_safe_remove(filepaths.private_API_host_file)
|
||||
_safe_remove(filepaths.daemon_mark_file)
|
||||
_safe_remove(filepaths.lock_file)
|
@ -3,5 +3,5 @@ echo This script is only intended for use in Onionr development, as it uses a ra
|
||||
set ONIONR_HOME=data%random%
|
||||
echo Using profile: %ONIONR_HOME%
|
||||
setlocal
|
||||
chdir onionr
|
||||
chdir src
|
||||
python __init__.py %*
|
||||
|
@ -1,4 +1,4 @@
|
||||
@echo off
|
||||
setlocal
|
||||
chdir onionr
|
||||
chdir src
|
||||
python __init__.py %*
|
||||
|
@ -22,30 +22,29 @@
|
||||
'''
|
||||
|
||||
# Set the user's locale for encoding reasons
|
||||
import locale
|
||||
import locale # noqa
|
||||
locale.setlocale(locale.LC_ALL, '')
|
||||
|
||||
ran_as_script = False
|
||||
if __name__ == "__main__": ran_as_script = True
|
||||
|
||||
# Import standard libraries
|
||||
import sys
|
||||
import sys # noqa
|
||||
|
||||
# 3rd party lib imports
|
||||
# Ensure that PySocks is installed
|
||||
try:
|
||||
from urllib3.contrib.socks import SOCKSProxyManager
|
||||
except ModuleNotFoundError:
|
||||
# check here or else we get error when onionr runs with tor
|
||||
raise ModuleNotFoundError("You need the PySocks module (for use with socks5 proxy to use Tor)")
|
||||
from etc import dependencycheck # noqa
|
||||
except ModuleNotFoundError as e:
|
||||
print('Onionr needs ' + str(e) + ' installed')
|
||||
|
||||
# Onionr imports
|
||||
from etc import onionrvalues # For different Onionr related constants such as versions
|
||||
import onionrsetup as setup
|
||||
|
||||
min_ver = onionrvalues.MIN_PY_VERSION
|
||||
|
||||
# Ensure we have at least the minimum python version
|
||||
if sys.version_info[0] == 2 or sys.version_info[1] < onionrvalues.MIN_PY_VERSION:
|
||||
sys.stderr.write('Error, Onionr requires Python 3.%s+\n' % (onionrvalues.MIN_PY_VERSION,))
|
||||
if sys.version_info[0] == 2 or sys.version_info[1] < min_ver:
|
||||
sys.stderr.write('Error, Onionr requires Python 3.' + str(min_ver) + '\n')
|
||||
sys.exit(1)
|
||||
|
||||
# Create Onionr data directories, must be done before most imports
|
||||
@ -58,19 +57,21 @@ from onionrplugins import onionrevents as events
|
||||
setup.setup_config()
|
||||
setup.setup_default_plugins()
|
||||
|
||||
|
||||
def onionr_main():
|
||||
"""Onionr entrypoint, start command processor"""
|
||||
parser.register()
|
||||
|
||||
|
||||
if ran_as_script:
|
||||
onionr_main()
|
||||
|
||||
# Cleanup standard out/err because Python refuses to do it itsself
|
||||
try:
|
||||
sys.stderr.close()
|
||||
except (IOError, BrokenPipeError) as e:
|
||||
except (IOError, BrokenPipeError):
|
||||
pass
|
||||
try:
|
||||
sys.stdout.close()
|
||||
except (IOError, BrokenPipeError) as e:
|
||||
except (IOError, BrokenPipeError):
|
||||
pass
|
@ -1,7 +1,7 @@
|
||||
"""
|
||||
Onionr - Private P2P Communication
|
||||
|
||||
Lib to keep Onionr up to date
|
||||
cleanup files
|
||||
"""
|
||||
"""
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
@ -17,14 +17,16 @@
|
||||
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 import onionrblockapi
|
||||
import os, filepaths
|
||||
|
||||
from etc import onionrvalues
|
||||
import onionrexceptions
|
||||
import notifier
|
||||
def _safe_remove(path):
|
||||
try:
|
||||
os.remove(path)
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
|
||||
def update_event(bl)->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.")
|
||||
def delete_run_files():
|
||||
_safe_remove(filepaths.public_API_host_file)
|
||||
_safe_remove(filepaths.private_API_host_file)
|
||||
_safe_remove(filepaths.daemon_mark_file)
|
||||
_safe_remove(filepaths.lock_file)
|
1
src/etc/dependencycheck.py
Normal file
1
src/etc/dependencycheck.py
Normal file
@ -0,0 +1 @@
|
||||
from urllib3.contrib.socks import SOCKSProxyManager # noqa
|
@ -3,6 +3,16 @@
|
||||
|
||||
view and interact with onionr sites
|
||||
"""
|
||||
|
||||
from typing import Union
|
||||
|
||||
import onionrexceptions
|
||||
from onionrutils import mnemonickeys
|
||||
from onionrutils import stringvalidators
|
||||
from coredb import blockmetadb
|
||||
from onionrblocks.onionrblockapi import Block
|
||||
from onionrtypes import BlockHash
|
||||
|
||||
"""
|
||||
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
|
||||
@ -17,21 +27,21 @@
|
||||
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 onionrexceptions
|
||||
from onionrutils import mnemonickeys
|
||||
from onionrutils import stringvalidators
|
||||
from coredb import blockmetadb
|
||||
from onionrblocks.onionrblockapi import Block
|
||||
|
||||
def find_site(user_id: str)->Union[str, None]:
|
||||
"""Returns block hash string for latest block for a site by a given user id"""
|
||||
if '-' in user_id: user_id = mnemonickeys.get_base32(user_id)
|
||||
if not stringvalidators.validate_pub_key(user_id): raise onionrexceptions.InvalidPubkey
|
||||
def find_site(user_id: str) -> Union[BlockHash, None]:
|
||||
"""Returns block hash str for latest block for a site by a given user id"""
|
||||
# If mnemonic delim in key, convert to base32 version
|
||||
if mnemonickeys.DELIMITER in user_id:
|
||||
user_id = mnemonickeys.get_base32(user_id)
|
||||
|
||||
if not stringvalidators.validate_pub_key(user_id):
|
||||
raise onionrexceptions.InvalidPubkey
|
||||
|
||||
found_site = None
|
||||
sites = blockmetadb.get_blocks_by_type('zsite')
|
||||
|
||||
# Find site by searching all site blocks. eww O(N) ☹️, TODO: event based
|
||||
for site in sites:
|
||||
site = Block(site)
|
||||
if site.isSigner(user_id) and site.verifySig():
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user