From cedd01c98f67c9ecc7dbb8c30680cb03b091e0eb Mon Sep 17 00:00:00 2001 From: Kevin F Date: Sun, 6 Feb 2022 19:18:53 -0600 Subject: [PATCH] Removed netcontroller Removed etc (moving most to onionrutils) Small refactoring --- run-onionr-node.py | 2 +- src/__init__.py | 4 +- src/apiservers/private/__init__.py | 2 +- src/blockdb/__init__.py | 1 - src/coredb/keydb/addkeys.py | 2 +- src/coredb/keydb/listkeys.py | 57 ++++++++--------- src/coredb/keydb/removekeys.py | 45 +++++++------- src/coredb/keydb/userinfo.py | 61 ++++++++++--------- src/etc/README.md | 9 --- src/etc/__init__.py | 0 src/etc/humanreadabletime.py | 38 ------------ src/httpapi/miscclientapi/endpoints.py | 2 +- src/netcontroller/__init__.py | 11 ---- src/onionrcommands/daemonlaunch/__init__.py | 13 +--- src/onionrcommands/onionrstatistics.py | 2 +- src/onionrcommands/pubkeymanager.py | 2 +- src/onionrcommands/restartonionr.py | 4 +- src/onionrcommands/version.py | 2 +- src/onionrcrypto/generate.py | 22 +++---- src/onionrsetup/setupconfig.py | 8 +-- src/onionrusers/onionrusers.py | 2 +- src/onionrutils/basicrequests.py | 2 +- src/{etc => onionrutils}/cleanup/__init__.py | 0 src/{etc => onionrutils}/dependencycheck.py | 0 .../getopenport.py | 0 src/onionrutils/mnemonickeys.py | 47 +++++++------- src/onionrutils/validatemetadata.py | 2 +- src/{etc => onionrutils}/waitforsetvar.py | 0 src/{etc => }/onionrvalues.py | 0 src/utils/hastor.py | 4 -- src/utils/logoheader.py | 2 +- tests/test_cleanup.py | 2 +- tests/test_getopenport.py | 4 +- tests/test_onionrvalues.py | 2 +- tests/test_waitforsetvars.py | 2 +- 35 files changed, 143 insertions(+), 213 deletions(-) delete mode 100755 src/etc/README.md delete mode 100644 src/etc/__init__.py delete mode 100755 src/etc/humanreadabletime.py delete mode 100755 src/netcontroller/__init__.py rename src/{etc => onionrutils}/cleanup/__init__.py (100%) rename src/{etc => onionrutils}/dependencycheck.py (100%) rename src/{netcontroller => onionrutils}/getopenport.py (100%) rename src/{etc => onionrutils}/waitforsetvar.py (100%) rename src/{etc => }/onionrvalues.py (100%) delete mode 100644 src/utils/hastor.py diff --git a/run-onionr-node.py b/run-onionr-node.py index 2419c72f..bd8f1609 100755 --- a/run-onionr-node.py +++ b/run-onionr-node.py @@ -15,7 +15,7 @@ import sys script_dir = os.path.dirname(os.path.realpath(__file__)) sys.path.append(script_dir + '/src/') -from etc import onionrvalues +import onionrvalues sub_script = script_dir + '/' + onionrvalues.SCRIPT_NAME diff --git a/src/__init__.py b/src/__init__.py index 5d4a62ca..bf5baf9e 100755 --- a/src/__init__.py +++ b/src/__init__.py @@ -48,7 +48,7 @@ if __name__ == "__main__": ran_as_script = True # Import standard libraries try: - from etc import dependencycheck # noqa + from onionrutils import dependencycheck # noqa except ModuleNotFoundError as e: print('Missing requirement: ' + str(e) + ' installed') sys.exit(1) @@ -60,7 +60,7 @@ from filenuke import nuke # noqa # Onionr imports # For different Onionr related constants such as versions -from etc import onionrvalues # noqa +import onionrvalues # noqa import onionrexceptions # noqa import onionrsetup as setup # noqa diff --git a/src/apiservers/private/__init__.py b/src/apiservers/private/__init__.py index 61f2f40f..01f10af1 100644 --- a/src/apiservers/private/__init__.py +++ b/src/apiservers/private/__init__.py @@ -13,7 +13,7 @@ import httpapi from filepaths import private_API_host_file import logger -from etc import waitforsetvar +from onionrutils import waitforsetvar from . import register_private_blueprints import config diff --git a/src/blockdb/__init__.py b/src/blockdb/__init__.py index 900684f9..369a7f76 100644 --- a/src/blockdb/__init__.py +++ b/src/blockdb/__init__.py @@ -6,7 +6,6 @@ from utils import identifyhome block_db_path = identifyhome.identify_home() + 'blockdata' - def store_vdf_block(block: Block): db.set(block_db_path, block.id, block.raw) diff --git a/src/coredb/keydb/addkeys.py b/src/coredb/keydb/addkeys.py index 8d76eeb8..f093991a 100644 --- a/src/coredb/keydb/addkeys.py +++ b/src/coredb/keydb/addkeys.py @@ -7,7 +7,7 @@ from onionrutils import stringvalidators from . import listkeys from .. import dbfiles import onionrcrypto -from etc import onionrvalues +import onionrvalues """ 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 diff --git a/src/coredb/keydb/listkeys.py b/src/coredb/keydb/listkeys.py index 28d58657..959a65a1 100644 --- a/src/coredb/keydb/listkeys.py +++ b/src/coredb/keydb/listkeys.py @@ -1,36 +1,37 @@ -''' - Onionr - Private P2P Communication +""" +Onionr - Private P2P Communication - get lists for user keys or transport addresses -''' -''' - 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 . -''' +get lists for user keys +""" import sqlite3 import logger from onionrutils import epoch -from etc import onionrvalues +import onionrvalues from .. import dbfiles from . import userinfo +""" +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 list_pub_keys(randomOrder=True, getPow=False, trust=0): - ''' - Return a list of public keys (misleading function name) + """ + Return a list of public keys (misleading function name) - randomOrder determines if the list should be in a random order - trust sets the minimum trust to list - ''' + randomOrder determines if the list should be in a random order + trust sets the minimum trust to list + """ conn = sqlite3.connect(dbfiles.user_id_info_db, timeout=onionrvalues.DATABASE_LOCK_TIMEOUT) c = conn.cursor() @@ -45,18 +46,18 @@ def list_pub_keys(randomOrder=True, getPow=False, trust=0): else: payload = 'SELECT * FROM peers WHERE trust >= ?;' - peerList = [] + peer_list = [] for i in c.execute(payload, (trust,)): try: if len(i[0]) != 0: if getPow: - peerList.append(i[0] + '-' + i[1]) + peer_list.append(i[0] + '-' + i[1]) else: - peerList.append(i[0]) + peer_list.append(i[0]) except TypeError: pass conn.close() - return peerList + return peer_list diff --git a/src/coredb/keydb/removekeys.py b/src/coredb/keydb/removekeys.py index 1dd0fb39..47c53672 100644 --- a/src/coredb/keydb/removekeys.py +++ b/src/coredb/keydb/removekeys.py @@ -1,38 +1,37 @@ -''' - Onionr - Private P2P Communication +""" +Onionr - Private P2P Communication - Remove a transport address but don't ban them -''' -''' - 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 . -''' +Remove a transport address but don't ban them +""" import sqlite3 from onionrplugins import onionrevents as events from onionrutils import stringvalidators from onionrutils import mnemonickeys from .. import dbfiles -from etc import onionrvalues +import onionrvalues +""" +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 remove_user(pubkey: str)->bool: - ''' - Remove a user from the user database - ''' + """Remove a user from the user database""" pubkey = mnemonickeys.get_base32(pubkey) if stringvalidators.validate_pub_key(pubkey): - conn = sqlite3.connect(dbfiles.user_id_info_db, timeout=onionrvalues.DATABASE_LOCK_TIMEOUT) + conn = sqlite3.connect( + dbfiles.user_id_info_db, + timeout=onionrvalues.DATABASE_LOCK_TIMEOUT) c = conn.cursor() t = (pubkey,) c.execute('Delete from peers where id=?;', t) diff --git a/src/coredb/keydb/userinfo.py b/src/coredb/keydb/userinfo.py index 3f055b49..96c61781 100644 --- a/src/coredb/keydb/userinfo.py +++ b/src/coredb/keydb/userinfo.py @@ -1,37 +1,38 @@ -''' - Onionr - Private P2P Communication +""" +Onionr - Private P2P Communication - get or set information about a user id -''' -''' - 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 . -''' +get or set information about a user id +""" import sqlite3 from .. import dbfiles -from etc import onionrvalues +import onionrvalues + +""" +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 get_user_info(peer, info): - ''' - Get info about a peer from their database entry + """ + Get info about a peer from their database entry - id text 0 - name text, 1 - adders text, 2 - dateSeen not null, 3 - trust int 4 - hashID text 5 - ''' + id text 0 + name text, 1 + adders text, 2 + dateSeen not null, 3 + trust int 4 + hashID text 5 + """ conn = sqlite3.connect(dbfiles.user_id_info_db, timeout=onionrvalues.DATABASE_LOCK_TIMEOUT) c = conn.cursor() @@ -54,9 +55,9 @@ def get_user_info(peer, info): return retVal def set_peer_info(peer, key, data): - ''' + """ Update a peer for a key - ''' + """ conn = sqlite3.connect(dbfiles.user_id_info_db, timeout=onionrvalues.DATABASE_LOCK_TIMEOUT) c = conn.cursor() diff --git a/src/etc/README.md b/src/etc/README.md deleted file mode 100755 index 46698239..00000000 --- a/src/etc/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# etc - -Files that don't really fit anywhere else, but aren't used very frequently. - -## Files - -humanreadabletime.py: take integer seconds and return a human readable time string - -onionrvalues.py: spec values for onionr blocks and other things \ No newline at end of file diff --git a/src/etc/__init__.py b/src/etc/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/src/etc/humanreadabletime.py b/src/etc/humanreadabletime.py deleted file mode 100755 index 7e3ff3bc..00000000 --- a/src/etc/humanreadabletime.py +++ /dev/null @@ -1,38 +0,0 @@ -''' - Onionr - Private P2P Communication - - human_readable_time takes integer seconds and returns a human readable string -''' -''' - 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 human_readable_time(seconds): - build = '' - - units = { - 'year' : 31557600, - 'month' : (31557600 / 12), - 'day' : 86400, - 'hour' : 3600, - 'minute' : 60, - 'second' : 1 - } - - for unit in units: - amnt_unit = int(seconds / units[unit]) - if amnt_unit >= 1: - seconds -= amnt_unit * units[unit] - build += '%s %s' % (amnt_unit, unit) + ('s' if amnt_unit != 1 else '') + ' ' - - return build.strip() \ No newline at end of file diff --git a/src/httpapi/miscclientapi/endpoints.py b/src/httpapi/miscclientapi/endpoints.py index 3e91c08c..2431b487 100644 --- a/src/httpapi/miscclientapi/endpoints.py +++ b/src/httpapi/miscclientapi/endpoints.py @@ -17,7 +17,7 @@ import onionrcrypto import config from onionrutils import mnemonickeys from onionrutils import bytesconverter -from etc import onionrvalues +import onionrvalues from utils import reconstructhash """ This program is free software: you can redistribute it and/or modify diff --git a/src/netcontroller/__init__.py b/src/netcontroller/__init__.py deleted file mode 100755 index ece995b8..00000000 --- a/src/netcontroller/__init__.py +++ /dev/null @@ -1,11 +0,0 @@ -from . import getopenport -from .getopenport import get_open_port -import os -from shutil import which - -def tor_binary(): - """Return tor binary path or none if not exists""" - tor_path = './tor' - if not os.path.exists(tor_path): - tor_path = which('tor') - return tor_path diff --git a/src/onionrcommands/daemonlaunch/__init__.py b/src/onionrcommands/daemonlaunch/__init__.py index d724eaf2..97f46302 100755 --- a/src/onionrcommands/daemonlaunch/__init__.py +++ b/src/onionrcommands/daemonlaunch/__init__.py @@ -24,9 +24,9 @@ from onionrplugins import onionrevents as events from onionrutils import localcommand from utils import identifyhome import filepaths -from etc import onionrvalues, cleanup +import onionrvalues +from onionrutils import cleanup from onionrcrypto import getourkeypair -from utils import hastor import runtests from httpapi import daemoneventsapi from .. import version @@ -87,15 +87,6 @@ def daemon(): sys.exit(0) signal.signal(signal.SIGTERM, _handle_sig_term) - # Determine if Onionr is in offline mode. - # When offline, Onionr can only use LAN and disk transport - offline_mode = config.get('general.offline_mode', False) - - if not hastor.has_tor(): - offline_mode = True - logger.error("Tor is not present in system path or Onionr directory", - terminal=True) - # Create shared objects shared_state = toomanyobjs.TooMany() diff --git a/src/onionrcommands/onionrstatistics.py b/src/onionrcommands/onionrstatistics.py index fd54146a..8aa13ca8 100755 --- a/src/onionrcommands/onionrstatistics.py +++ b/src/onionrcommands/onionrstatistics.py @@ -9,7 +9,7 @@ from utils import sizeutils, getconsolewidth, identifyhome from coredb import keydb import onionrcrypto import config -from etc import onionrvalues +import onionrvalues from filepaths import lock_file import psutil diff --git a/src/onionrcommands/pubkeymanager.py b/src/onionrcommands/pubkeymanager.py index 4b9c263f..138b0717 100755 --- a/src/onionrcommands/pubkeymanager.py +++ b/src/onionrcommands/pubkeymanager.py @@ -14,7 +14,7 @@ from onionrutils import stringvalidators, bytesconverter import config import keymanager import onionrcrypto -from etc import onionrvalues +import onionrvalues """ 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 diff --git a/src/onionrcommands/restartonionr.py b/src/onionrcommands/restartonionr.py index 2104513e..7816902f 100644 --- a/src/onionrcommands/restartonionr.py +++ b/src/onionrcommands/restartonionr.py @@ -9,8 +9,8 @@ import subprocess # nosec from psutil import Process -from etc import onionrvalues -from etc import cleanup +import onionrvalues +from onionrutils import cleanup from onionrutils import localcommand import logger import filepaths diff --git a/src/onionrcommands/version.py b/src/onionrcommands/version.py index 9d60d6ea..395cb8ed 100644 --- a/src/onionrcommands/version.py +++ b/src/onionrcommands/version.py @@ -4,7 +4,7 @@ Command to show version info """ import platform from utils import identifyhome -from etc import onionrvalues +import onionrvalues import logger """ This program is free software: you can redistribute it and/or modify diff --git a/src/onionrcrypto/generate.py b/src/onionrcrypto/generate.py index 4fdacd9b..298198d7 100644 --- a/src/onionrcrypto/generate.py +++ b/src/onionrcrypto/generate.py @@ -8,20 +8,20 @@ import nacl.pwhash import onionrexceptions from onionrutils import bytesconverter -from etc import onionrvalues +import onionrvalues """ - 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 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. +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 . +You should have received a copy of the GNU General Public License +along with this program. If not, see . """ diff --git a/src/onionrsetup/setupconfig.py b/src/onionrsetup/setupconfig.py index 56319e3f..91f6b668 100755 --- a/src/onionrsetup/setupconfig.py +++ b/src/onionrsetup/setupconfig.py @@ -9,8 +9,8 @@ import ujson as json import config import logger -import netcontroller -from etc import onionrvalues +import onionrvalues +from onionrutils import getopenport from logger.settings import * from utils import readstatic """ @@ -81,10 +81,10 @@ def setup_config(): if type(config.get('client.webpassword')) is type(None): config.set('client.webpassword', base64.b16encode(os.urandom(32)).decode('utf-8'), savefile=True) if type(config.get('client.client.port')) is type(None): - randomPort = netcontroller.getopenport.get_open_port() + randomPort = getopenport.get_open_port() config.set('client.client.port', randomPort, savefile=True) if type(config.get('client.public.port')) is type(None): - randomPort = netcontroller.getopenport.get_open_port() + randomPort = getopenport.get_open_port() config.set('client.public.port', randomPort, savefile=True) if type(config.get('client.api_version')) is type(None): config.set('client.api_version', onionrvalues.API_VERSION, savefile=True) \ No newline at end of file diff --git a/src/onionrusers/onionrusers.py b/src/onionrusers/onionrusers.py index 62163f3b..090cf3ed 100755 --- a/src/onionrusers/onionrusers.py +++ b/src/onionrusers/onionrusers.py @@ -14,7 +14,7 @@ import nacl.exceptions from coredb import keydb, dbfiles import onionrcrypto from onionrcrypto import getourkeypair -from etc.onionrvalues import DATABASE_LOCK_TIMEOUT +from onionrvalues import DATABASE_LOCK_TIMEOUT """ 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 diff --git a/src/onionrutils/basicrequests.py b/src/onionrutils/basicrequests.py index 64f4fc95..873b145e 100644 --- a/src/onionrutils/basicrequests.py +++ b/src/onionrutils/basicrequests.py @@ -7,7 +7,7 @@ from urllib.parse import urlparse import requests, streamedrequests import logger, onionrexceptions -from etc import onionrvalues +import onionrvalues from . import localcommand ''' This program is free software: you can redistribute it and/or modify diff --git a/src/etc/cleanup/__init__.py b/src/onionrutils/cleanup/__init__.py similarity index 100% rename from src/etc/cleanup/__init__.py rename to src/onionrutils/cleanup/__init__.py diff --git a/src/etc/dependencycheck.py b/src/onionrutils/dependencycheck.py similarity index 100% rename from src/etc/dependencycheck.py rename to src/onionrutils/dependencycheck.py diff --git a/src/netcontroller/getopenport.py b/src/onionrutils/getopenport.py similarity index 100% rename from src/netcontroller/getopenport.py rename to src/onionrutils/getopenport.py diff --git a/src/onionrutils/mnemonickeys.py b/src/onionrutils/mnemonickeys.py index 2f6ed44d..6f727e52 100644 --- a/src/onionrutils/mnemonickeys.py +++ b/src/onionrutils/mnemonickeys.py @@ -1,45 +1,46 @@ -''' - Onionr - Private P2P Communication +""" +Onionr - Private P2P Communication - convert a base32 string (intended for ed25519 user ids) to pgp word list -''' -''' - 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 . -''' +convert a base32 string (intended for ed25519 user ids) to pgp word list +""" import base64 import niceware import unpaddedbase32 import onionrcrypto -from etc import onionrvalues +import onionrvalues +""" +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 . +""" + DELIMITER = '-' def get_human_readable_ID(pub=''): - '''gets a human readable ID from a public key''' + """gets a human readable ID from a public key""" if pub == '': pub = onionrcrypto.pub_key - + if not len(pub) == onionrvalues.MAIN_PUBLIC_KEY_SIZE: pub = base64.b32decode(pub) - + return DELIMITER.join(niceware.bytes_to_passphrase(pub)) #return niceware.bytes_to_passphrase(pub).replace(' ', DELIMITER) def get_base32(words): - '''converts mnemonic to base32''' + """converts mnemonic to base32""" if DELIMITER not in words and not type(words) in (type(list), type(tuple)): return words try: diff --git a/src/onionrutils/validatemetadata.py b/src/onionrutils/validatemetadata.py index 2f221a06..da042333 100644 --- a/src/onionrutils/validatemetadata.py +++ b/src/onionrutils/validatemetadata.py @@ -6,7 +6,7 @@ from json import JSONDecodeError import ujson as json import logger, onionrexceptions -from etc import onionrvalues +import onionrvalues from . import stringvalidators, epoch, bytesconverter import config, filepaths, onionrcrypto """ diff --git a/src/etc/waitforsetvar.py b/src/onionrutils/waitforsetvar.py similarity index 100% rename from src/etc/waitforsetvar.py rename to src/onionrutils/waitforsetvar.py diff --git a/src/etc/onionrvalues.py b/src/onionrvalues.py similarity index 100% rename from src/etc/onionrvalues.py rename to src/onionrvalues.py diff --git a/src/utils/hastor.py b/src/utils/hastor.py deleted file mode 100644 index f94298e8..00000000 --- a/src/utils/hastor.py +++ /dev/null @@ -1,4 +0,0 @@ -import netcontroller - -def has_tor(): - return netcontroller.tor_binary() is not None \ No newline at end of file diff --git a/src/utils/logoheader.py b/src/utils/logoheader.py index 9daf6431..4ec8c730 100644 --- a/src/utils/logoheader.py +++ b/src/utils/logoheader.py @@ -1,7 +1,7 @@ import sys, os from . import readstatic import logger -from etc import onionrvalues +import onionrvalues def header(message = logger.colors.fg.pink + logger.colors.bold + 'Onionr' + logger.colors.reset + logger.colors.fg.pink + ' has started.'): if onionrvalues.DEVELOPMENT_MODE: return diff --git a/tests/test_cleanup.py b/tests/test_cleanup.py index 9df2c182..50bff161 100644 --- a/tests/test_cleanup.py +++ b/tests/test_cleanup.py @@ -10,7 +10,7 @@ import unittest, json from utils import identifyhome, createdirs createdirs.create_dirs() -from etc.cleanup import delete_run_files +from onionrutils.cleanup import delete_run_files import filepaths diff --git a/tests/test_getopenport.py b/tests/test_getopenport.py index 9a690f02..a31a3584 100644 --- a/tests/test_getopenport.py +++ b/tests/test_getopenport.py @@ -7,11 +7,11 @@ import unittest, uuid TEST_DIR = 'testdata/%s-%s' % (uuid.uuid4(), os.path.basename(__file__)) + '/' print("Test directory:", TEST_DIR) os.environ["ONIONR_HOME"] = TEST_DIR -import netcontroller +from onionrutils import getopenport class GetOpenPortTest(unittest.TestCase): def test_open_port(self): - open_port = int(netcontroller.get_open_port()) + open_port = int(getopenport.get_open_port()) self.assertGreaterEqual(open_port, 1024) unittest.main() diff --git a/tests/test_onionrvalues.py b/tests/test_onionrvalues.py index 21f601ae..8e12586c 100644 --- a/tests/test_onionrvalues.py +++ b/tests/test_onionrvalues.py @@ -9,7 +9,7 @@ print("Test directory:", TEST_DIR) os.environ["ONIONR_HOME"] = TEST_DIR from utils import identifyhome, createdirs -from etc import onionrvalues +import onionrvalues class TestOnionrValues(unittest.TestCase): def test_api_version(self): diff --git a/tests/test_waitforsetvars.py b/tests/test_waitforsetvars.py index a5a41195..f65ef897 100644 --- a/tests/test_waitforsetvars.py +++ b/tests/test_waitforsetvars.py @@ -9,7 +9,7 @@ from utils import createdirs createdirs.create_dirs() from onionrcrypto import getourkeypair getourkeypair.get_keypair() -from etc import waitforsetvar +from onionrutils import waitforsetvar def set_test_var_delay(obj, delay=0): if delay > 0: time.sleep(delay)