From 720efe4fca3706b320e8d3987a9eb04179447031 Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Wed, 20 Nov 2019 04:52:50 -0600 Subject: [PATCH] renamed onionr dir and bugfixes/linting progress --- .env | 1 + .gitignore | 42 +++++------ make-release.sh | 2 +- onionr.sh | 2 +- onionr/etc/cleanup/__init__.py | 13 ---- run-windows-dev.bat | 2 +- run-windows.bat | 2 +- {onionr => src}/__init__.py | 25 ++++--- {onionr => src}/apiservers/README.md | 0 {onionr => src}/apiservers/__init__.py | 0 {onionr => src}/apiservers/private/README.md | 0 .../apiservers/private/__init__.py | 0 .../private/register_private_blueprints.py | 0 {onionr => src}/apiservers/public/__init__.py | 0 {onionr => src}/communicator/README.md | 0 {onionr => src}/communicator/__init__.py | 0 .../communicator/bootstrappeers.py | 0 .../communicator/onlinepeers/README.md | 0 .../communicator/onlinepeers/__init__.py | 0 .../onlinepeers/clearofflinepeer.py | 0 .../communicator/onlinepeers/onlinepeers.py | 0 .../onlinepeers/pickonlinepeers.py | 0 .../onlinepeers/removeonlinepeer.py | 0 {onionr => src}/communicator/peeraction.py | 0 .../communicator/uploadqueue/__init__.py | 0 {onionr => src}/communicatorutils/README.md | 0 {onionr => src}/communicatorutils/__init__.py | 0 .../communicatorutils/announcenode.py | 0 .../communicatorutils/connectnewpeers.py | 0 .../communicatorutils/cooldownpeer.py | 0 .../communicatorutils/daemonqueuehandler.py | 0 .../communicatorutils/deniableinserts.py | 0 .../downloadblocks/__init__.py | 0 .../downloadblocks/shoulddownload.py | 0 .../communicatorutils/housekeeping.py | 0 .../communicatorutils/lookupadders.py | 0 .../communicatorutils/lookupblocks.py | 0 {onionr => src}/communicatorutils/netcheck.py | 0 .../onionrcommunicatortimers.py | 0 .../communicatorutils/proxypicker.py | 0 .../communicatorutils/restarttor.py | 0 .../communicatorutils/servicecreator.py | 0 .../uploadblocks/__init__.py | 0 .../communicatorutils/uploadblocks/session.py | 0 .../uploadblocks/sessionmanager.py | 0 {onionr => src}/config.py | 0 {onionr => src}/coredb/__init__.py | 0 .../coredb/blockmetadb/__init__.py | 0 {onionr => src}/coredb/blockmetadb/add.py | 0 .../coredb/blockmetadb/expiredblocks.py | 0 .../coredb/blockmetadb/updateblockinfo.py | 0 .../coredb/daemonqueue/__init__.py | 0 {onionr => src}/coredb/dbfiles.py | 0 {onionr => src}/coredb/keydb/__init__.py | 0 {onionr => src}/coredb/keydb/addkeys.py | 0 {onionr => src}/coredb/keydb/listkeys.py | 0 {onionr => src}/coredb/keydb/removekeys.py | 0 {onionr => src}/coredb/keydb/transportinfo.py | 0 {onionr => src}/coredb/keydb/userinfo.py | 0 {onionr => src}/etc/README.md | 0 {onionr => src}/etc/__init__.py | 0 .../updater => src/etc/cleanup}/__init__.py | 22 +++--- src/etc/dependencycheck.py | 1 + {onionr => src}/etc/humanreadabletime.py | 0 {onionr => src}/etc/onionrvalues.py | 0 {onionr => src}/etc/powchoice.py | 0 {onionr => src}/etc/waitforsetvar.py | 0 {onionr => src}/filepaths/__init__.py | 0 {onionr => src}/httpapi/README.md | 0 {onionr => src}/httpapi/__init__.py | 0 {onionr => src}/httpapi/apiutils/__init__.py | 0 .../httpapi/apiutils/getblockdata.py | 0 {onionr => src}/httpapi/apiutils/setbindip.py | 0 {onionr => src}/httpapi/apiutils/shutdown.py | 0 {onionr => src}/httpapi/configapi/__init__.py | 0 .../httpapi/directconnections/__init__.py | 0 {onionr => src}/httpapi/fdsafehandler.py | 0 .../httpapi/friendsapi/__init__.py | 0 {onionr => src}/httpapi/insertblock.py | 0 .../httpapi/miscclientapi/__init__.py | 0 .../httpapi/miscclientapi/endpoints.py | 0 .../httpapi/miscclientapi/getblocks.py | 0 .../httpapi/miscclientapi/motd/__init__.py | 0 .../httpapi/miscclientapi/staticfiles.py | 0 .../httpapi/miscpublicapi/__init__.py | 0 .../httpapi/miscpublicapi/announce.py | 0 .../httpapi/miscpublicapi/endpoints.py | 0 .../httpapi/miscpublicapi/getblocks.py | 0 .../httpapi/miscpublicapi/upload.py | 0 .../httpapi/onionrsitesapi/__init__.py | 0 .../httpapi/onionrsitesapi/findsite.py | 30 +++++--- .../httpapi/onionrsitesapi/sitefiles.py | 0 .../httpapi/profilesapi/__init__.py | 0 .../httpapi/profilesapi/profiles.py | 0 {onionr => src}/httpapi/security/__init__.py | 0 {onionr => src}/httpapi/security/client.py | 0 .../httpapi/security/pluginwhitelist.py | 0 {onionr => src}/httpapi/security/public.py | 0 {onionr => src}/httpapi/themeapi/__init__.py | 0 {onionr => src}/keymanager.py | 0 {onionr => src}/logger/__init__.py | 0 {onionr => src}/logger/colors.py | 0 {onionr => src}/logger/confirm.py | 0 {onionr => src}/logger/log.py | 0 {onionr => src}/logger/raw.py | 0 {onionr => src}/logger/readline.py | 0 {onionr => src}/logger/settings.py | 0 {onionr => src}/netcontroller/__init__.py | 0 {onionr => src}/netcontroller/getopenport.py | 0 {onionr => src}/netcontroller/netcontrol.py | 0 {onionr => src}/netcontroller/rebuildtor.py | 0 {onionr => src}/netcontroller/torbinary.py | 0 .../netcontroller/torcontroller.py | 0 {onionr => src}/notifier/__init__.py | 0 {onionr => src}/onionrblocks/__init__.py | 0 {onionr => src}/onionrblocks/blockimporter.py | 0 {onionr => src}/onionrblocks/insert.py | 4 +- .../onionrblocks/onionrblacklist.py | 0 .../onionrblocks/onionrblockapi.py | 0 .../onionrblocks/storagecounter.py | 0 {onionr => src}/onionrcommands/README.md | 0 {onionr => src}/onionrcommands/__init__.py | 0 {onionr => src}/onionrcommands/banblocks.py | 0 .../onionrcommands/daemonlaunch.py | 0 .../onionrcommands/exportblocks.py | 0 .../onionrcommands/filecommands.py | 0 {onionr => src}/onionrcommands/keyadders.py | 0 {onionr => src}/onionrcommands/motdcreator.py | 0 .../onionrcommands/onionrstatistics.py | 0 .../onionrcommands/openwebinterface.py | 0 .../onionrcommands/parser/__init__.py | 2 +- .../onionrcommands/parser/arguments.py | 0 .../onionrcommands/parser/recommend.py | 0 .../onionrcommands/pubkeymanager.py | 0 .../onionrcommands/resetplugins.py | 0 {onionr => src}/onionrcommands/resettor.py | 0 .../onionrcommands/restartonionr.py | 0 .../onionrcommands/runtimetestcmd.py | 0 {onionr => src}/onionrcommands/sitecreator.py | 0 {onionr => src}/onionrcommands/softreset.py | 0 {onionr => src}/onionrcommands/version.py | 0 {onionr => src}/onionrcrypto/__init__.py | 0 .../onionrcrypto/cryptoutils/__init__.py | 0 .../cryptoutils/getpubfrompriv.py | 0 .../onionrcrypto/cryptoutils/randomshuffle.py | 0 .../cryptoutils/replayvalidation.py | 0 .../onionrcrypto/cryptoutils/safecompare.py | 0 .../onionrcrypto/cryptoutils/verifypow.py | 0 .../onionrcrypto/encryption/__init__.py | 0 {onionr => src}/onionrcrypto/generate.py | 0 {onionr => src}/onionrcrypto/getourkeypair.py | 0 {onionr => src}/onionrcrypto/hashers.py | 0 .../onionrcrypto/signing/__init__.py | 0 {onionr => src}/onionrexceptions.py | 0 {onionr => src}/onionrpeers/__init__.py | 0 {onionr => src}/onionrpeers/peercleanup.py | 0 {onionr => src}/onionrpeers/peerprofiles.py | 0 .../onionrpeers/scoresortedpeerlist.py | 0 {onionr => src}/onionrplugins/__init__.py | 0 {onionr => src}/onionrplugins/onionrevents.py | 0 .../onionrplugins/onionrpluginapi.py | 0 {onionr => src}/onionrproofs/__init__.py | 0 {onionr => src}/onionrproofs/subprocesspow.py | 74 ++++++++++++------- {onionr => src}/onionrservices/README.md | 0 {onionr => src}/onionrservices/__init__.py | 0 .../onionrservices/bootstrapservice.py | 0 .../onionrservices/connectionserver.py | 0 {onionr => src}/onionrservices/httpheaders.py | 0 {onionr => src}/onionrservices/pool.py | 0 .../onionrservices/serverexists.py | 0 .../onionrservices/warden/__init__.py | 0 .../onionrservices/warden/bootstrap.py | 0 .../onionrservices/warden/client.py | 0 .../onionrservices/warden/server.py | 0 {onionr => src}/onionrsetup/__init__.py | 0 {onionr => src}/onionrsetup/dbcreator.py | 0 .../onionrsetup/defaultpluginsetup.py | 0 {onionr => src}/onionrsetup/setupconfig.py | 0 {onionr => src}/onionrstorage/__init__.py | 36 ++++++--- {onionr => src}/onionrstorage/removeblock.py | 0 {onionr => src}/onionrstorage/setdata.py | 0 {onionr => src}/onionrtypes/__init__.py | 2 - {onionr => src}/onionrusers/README.md | 0 {onionr => src}/onionrusers/__init__.py | 0 {onionr => src}/onionrusers/contactmanager.py | 0 {onionr => src}/onionrusers/onionrusers.py | 0 {onionr => src}/onionrutils/__init__.py | 0 {onionr => src}/onionrutils/basicrequests.py | 0 .../onionrutils/blockmetadata/__init__.py | 0 .../onionrutils/blockmetadata/fromdata.py | 0 .../onionrutils/blockmetadata/hasblock.py | 0 .../onionrutils/blockmetadata/process.py | 0 {onionr => src}/onionrutils/bytesconverter.py | 0 .../onionrutils/checkcommunicator.py | 0 {onionr => src}/onionrutils/epoch.py | 0 {onionr => src}/onionrutils/escapeansi.py | 0 .../onionrutils/getclientapiserver.py | 0 .../onionrutils/importnewblocks.py | 8 +- {onionr => src}/onionrutils/localcommand.py | 0 {onionr => src}/onionrutils/mnemonickeys.py | 0 .../onionrutils/stringvalidators.py | 0 src/onionrutils/updater/__init__.py | 7 ++ .../onionrutils/validatemetadata.py | 13 ++-- {onionr => src}/runtests/__init__.py | 0 {onionr => src}/runtests/inserttest.py | 0 {onionr => src}/runtests/stresstest.py | 0 {onionr => src}/runtests/uicheck.py | 0 {onionr => src}/serializeddata.py | 23 +++--- {onionr => src}/utils/__init__.py | 0 .../utils/cachedconfig/__init__.py | 0 {onionr => src}/utils/createdirs.py | 5 +- {onionr => src}/utils/definewait.py | 0 {onionr => src}/utils/getconsolewidth.py | 0 {onionr => src}/utils/gethostname.py | 1 + {onionr => src}/utils/gettransports.py | 0 {onionr => src}/utils/hastor.py | 0 {onionr => src}/utils/identifyhome.py | 0 {onionr => src}/utils/logoheader.py | 0 {onionr => src}/utils/netutils.py | 0 {onionr => src}/utils/networkmerger.py | 0 {onionr => src}/utils/readstatic.py | 0 {onionr => src}/utils/reconstructhash.py | 0 {onionr => src}/utils/safezip.py | 0 {onionr => src}/utils/sizeutils.py | 0 {onionr => src}/vanityonionr/__init__.py | 0 static-data/www/mail/mail.js | 4 +- 226 files changed, 179 insertions(+), 142 deletions(-) create mode 100644 .env delete mode 100644 onionr/etc/cleanup/__init__.py rename {onionr => src}/__init__.py (74%) rename {onionr => src}/apiservers/README.md (100%) rename {onionr => src}/apiservers/__init__.py (100%) rename {onionr => src}/apiservers/private/README.md (100%) rename {onionr => src}/apiservers/private/__init__.py (100%) rename {onionr => src}/apiservers/private/register_private_blueprints.py (100%) rename {onionr => src}/apiservers/public/__init__.py (100%) rename {onionr => src}/communicator/README.md (100%) rename {onionr => src}/communicator/__init__.py (100%) rename {onionr => src}/communicator/bootstrappeers.py (100%) rename {onionr => src}/communicator/onlinepeers/README.md (100%) rename {onionr => src}/communicator/onlinepeers/__init__.py (100%) rename {onionr => src}/communicator/onlinepeers/clearofflinepeer.py (100%) rename {onionr => src}/communicator/onlinepeers/onlinepeers.py (100%) rename {onionr => src}/communicator/onlinepeers/pickonlinepeers.py (100%) rename {onionr => src}/communicator/onlinepeers/removeonlinepeer.py (100%) rename {onionr => src}/communicator/peeraction.py (100%) rename {onionr => src}/communicator/uploadqueue/__init__.py (100%) rename {onionr => src}/communicatorutils/README.md (100%) rename {onionr => src}/communicatorutils/__init__.py (100%) rename {onionr => src}/communicatorutils/announcenode.py (100%) rename {onionr => src}/communicatorutils/connectnewpeers.py (100%) rename {onionr => src}/communicatorutils/cooldownpeer.py (100%) rename {onionr => src}/communicatorutils/daemonqueuehandler.py (100%) rename {onionr => src}/communicatorutils/deniableinserts.py (100%) rename {onionr => src}/communicatorutils/downloadblocks/__init__.py (100%) rename {onionr => src}/communicatorutils/downloadblocks/shoulddownload.py (100%) rename {onionr => src}/communicatorutils/housekeeping.py (100%) rename {onionr => src}/communicatorutils/lookupadders.py (100%) rename {onionr => src}/communicatorutils/lookupblocks.py (100%) rename {onionr => src}/communicatorutils/netcheck.py (100%) rename {onionr => src}/communicatorutils/onionrcommunicatortimers.py (100%) rename {onionr => src}/communicatorutils/proxypicker.py (100%) rename {onionr => src}/communicatorutils/restarttor.py (100%) rename {onionr => src}/communicatorutils/servicecreator.py (100%) rename {onionr => src}/communicatorutils/uploadblocks/__init__.py (100%) rename {onionr => src}/communicatorutils/uploadblocks/session.py (100%) rename {onionr => src}/communicatorutils/uploadblocks/sessionmanager.py (100%) rename {onionr => src}/config.py (100%) rename {onionr => src}/coredb/__init__.py (100%) rename {onionr => src}/coredb/blockmetadb/__init__.py (100%) rename {onionr => src}/coredb/blockmetadb/add.py (100%) rename {onionr => src}/coredb/blockmetadb/expiredblocks.py (100%) rename {onionr => src}/coredb/blockmetadb/updateblockinfo.py (100%) rename {onionr => src}/coredb/daemonqueue/__init__.py (100%) rename {onionr => src}/coredb/dbfiles.py (100%) rename {onionr => src}/coredb/keydb/__init__.py (100%) rename {onionr => src}/coredb/keydb/addkeys.py (100%) rename {onionr => src}/coredb/keydb/listkeys.py (100%) rename {onionr => src}/coredb/keydb/removekeys.py (100%) rename {onionr => src}/coredb/keydb/transportinfo.py (100%) rename {onionr => src}/coredb/keydb/userinfo.py (100%) rename {onionr => src}/etc/README.md (100%) rename {onionr => src}/etc/__init__.py (100%) rename {onionr/onionrutils/updater => src/etc/cleanup}/__init__.py (58%) create mode 100644 src/etc/dependencycheck.py rename {onionr => src}/etc/humanreadabletime.py (100%) rename {onionr => src}/etc/onionrvalues.py (100%) rename {onionr => src}/etc/powchoice.py (100%) rename {onionr => src}/etc/waitforsetvar.py (100%) rename {onionr => src}/filepaths/__init__.py (100%) rename {onionr => src}/httpapi/README.md (100%) rename {onionr => src}/httpapi/__init__.py (100%) rename {onionr => src}/httpapi/apiutils/__init__.py (100%) rename {onionr => src}/httpapi/apiutils/getblockdata.py (100%) rename {onionr => src}/httpapi/apiutils/setbindip.py (100%) rename {onionr => src}/httpapi/apiutils/shutdown.py (100%) rename {onionr => src}/httpapi/configapi/__init__.py (100%) rename {onionr => src}/httpapi/directconnections/__init__.py (100%) rename {onionr => src}/httpapi/fdsafehandler.py (100%) rename {onionr => src}/httpapi/friendsapi/__init__.py (100%) rename {onionr => src}/httpapi/insertblock.py (100%) rename {onionr => src}/httpapi/miscclientapi/__init__.py (100%) rename {onionr => src}/httpapi/miscclientapi/endpoints.py (100%) rename {onionr => src}/httpapi/miscclientapi/getblocks.py (100%) rename {onionr => src}/httpapi/miscclientapi/motd/__init__.py (100%) rename {onionr => src}/httpapi/miscclientapi/staticfiles.py (100%) rename {onionr => src}/httpapi/miscpublicapi/__init__.py (100%) rename {onionr => src}/httpapi/miscpublicapi/announce.py (100%) rename {onionr => src}/httpapi/miscpublicapi/endpoints.py (100%) rename {onionr => src}/httpapi/miscpublicapi/getblocks.py (100%) rename {onionr => src}/httpapi/miscpublicapi/upload.py (100%) rename {onionr => src}/httpapi/onionrsitesapi/__init__.py (100%) rename {onionr => src}/httpapi/onionrsitesapi/findsite.py (70%) rename {onionr => src}/httpapi/onionrsitesapi/sitefiles.py (100%) rename {onionr => src}/httpapi/profilesapi/__init__.py (100%) rename {onionr => src}/httpapi/profilesapi/profiles.py (100%) rename {onionr => src}/httpapi/security/__init__.py (100%) rename {onionr => src}/httpapi/security/client.py (100%) rename {onionr => src}/httpapi/security/pluginwhitelist.py (100%) rename {onionr => src}/httpapi/security/public.py (100%) rename {onionr => src}/httpapi/themeapi/__init__.py (100%) rename {onionr => src}/keymanager.py (100%) rename {onionr => src}/logger/__init__.py (100%) rename {onionr => src}/logger/colors.py (100%) rename {onionr => src}/logger/confirm.py (100%) rename {onionr => src}/logger/log.py (100%) rename {onionr => src}/logger/raw.py (100%) rename {onionr => src}/logger/readline.py (100%) rename {onionr => src}/logger/settings.py (100%) rename {onionr => src}/netcontroller/__init__.py (100%) rename {onionr => src}/netcontroller/getopenport.py (100%) rename {onionr => src}/netcontroller/netcontrol.py (100%) rename {onionr => src}/netcontroller/rebuildtor.py (100%) rename {onionr => src}/netcontroller/torbinary.py (100%) rename {onionr => src}/netcontroller/torcontroller.py (100%) rename {onionr => src}/notifier/__init__.py (100%) rename {onionr => src}/onionrblocks/__init__.py (100%) rename {onionr => src}/onionrblocks/blockimporter.py (100%) rename {onionr => src}/onionrblocks/insert.py (98%) rename {onionr => src}/onionrblocks/onionrblacklist.py (100%) rename {onionr => src}/onionrblocks/onionrblockapi.py (100%) rename {onionr => src}/onionrblocks/storagecounter.py (100%) rename {onionr => src}/onionrcommands/README.md (100%) rename {onionr => src}/onionrcommands/__init__.py (100%) rename {onionr => src}/onionrcommands/banblocks.py (100%) rename {onionr => src}/onionrcommands/daemonlaunch.py (100%) rename {onionr => src}/onionrcommands/exportblocks.py (100%) rename {onionr => src}/onionrcommands/filecommands.py (100%) rename {onionr => src}/onionrcommands/keyadders.py (100%) rename {onionr => src}/onionrcommands/motdcreator.py (100%) rename {onionr => src}/onionrcommands/onionrstatistics.py (100%) rename {onionr => src}/onionrcommands/openwebinterface.py (100%) rename {onionr => src}/onionrcommands/parser/__init__.py (97%) rename {onionr => src}/onionrcommands/parser/arguments.py (100%) rename {onionr => src}/onionrcommands/parser/recommend.py (100%) rename {onionr => src}/onionrcommands/pubkeymanager.py (100%) rename {onionr => src}/onionrcommands/resetplugins.py (100%) rename {onionr => src}/onionrcommands/resettor.py (100%) rename {onionr => src}/onionrcommands/restartonionr.py (100%) rename {onionr => src}/onionrcommands/runtimetestcmd.py (100%) rename {onionr => src}/onionrcommands/sitecreator.py (100%) rename {onionr => src}/onionrcommands/softreset.py (100%) rename {onionr => src}/onionrcommands/version.py (100%) rename {onionr => src}/onionrcrypto/__init__.py (100%) rename {onionr => src}/onionrcrypto/cryptoutils/__init__.py (100%) rename {onionr => src}/onionrcrypto/cryptoutils/getpubfrompriv.py (100%) rename {onionr => src}/onionrcrypto/cryptoutils/randomshuffle.py (100%) rename {onionr => src}/onionrcrypto/cryptoutils/replayvalidation.py (100%) rename {onionr => src}/onionrcrypto/cryptoutils/safecompare.py (100%) rename {onionr => src}/onionrcrypto/cryptoutils/verifypow.py (100%) rename {onionr => src}/onionrcrypto/encryption/__init__.py (100%) rename {onionr => src}/onionrcrypto/generate.py (100%) rename {onionr => src}/onionrcrypto/getourkeypair.py (100%) rename {onionr => src}/onionrcrypto/hashers.py (100%) rename {onionr => src}/onionrcrypto/signing/__init__.py (100%) rename {onionr => src}/onionrexceptions.py (100%) rename {onionr => src}/onionrpeers/__init__.py (100%) rename {onionr => src}/onionrpeers/peercleanup.py (100%) rename {onionr => src}/onionrpeers/peerprofiles.py (100%) rename {onionr => src}/onionrpeers/scoresortedpeerlist.py (100%) rename {onionr => src}/onionrplugins/__init__.py (100%) rename {onionr => src}/onionrplugins/onionrevents.py (100%) rename {onionr => src}/onionrplugins/onionrpluginapi.py (100%) rename {onionr => src}/onionrproofs/__init__.py (100%) rename {onionr => src}/onionrproofs/subprocesspow.py (70%) rename {onionr => src}/onionrservices/README.md (100%) rename {onionr => src}/onionrservices/__init__.py (100%) rename {onionr => src}/onionrservices/bootstrapservice.py (100%) rename {onionr => src}/onionrservices/connectionserver.py (100%) rename {onionr => src}/onionrservices/httpheaders.py (100%) rename {onionr => src}/onionrservices/pool.py (100%) rename {onionr => src}/onionrservices/serverexists.py (100%) rename {onionr => src}/onionrservices/warden/__init__.py (100%) rename {onionr => src}/onionrservices/warden/bootstrap.py (100%) rename {onionr => src}/onionrservices/warden/client.py (100%) rename {onionr => src}/onionrservices/warden/server.py (100%) rename {onionr => src}/onionrsetup/__init__.py (100%) rename {onionr => src}/onionrsetup/dbcreator.py (100%) rename {onionr => src}/onionrsetup/defaultpluginsetup.py (100%) rename {onionr => src}/onionrsetup/setupconfig.py (100%) rename {onionr => src}/onionrstorage/__init__.py (85%) rename {onionr => src}/onionrstorage/removeblock.py (100%) rename {onionr => src}/onionrstorage/setdata.py (100%) rename {onionr => src}/onionrtypes/__init__.py (77%) rename {onionr => src}/onionrusers/README.md (100%) rename {onionr => src}/onionrusers/__init__.py (100%) rename {onionr => src}/onionrusers/contactmanager.py (100%) rename {onionr => src}/onionrusers/onionrusers.py (100%) rename {onionr => src}/onionrutils/__init__.py (100%) rename {onionr => src}/onionrutils/basicrequests.py (100%) rename {onionr => src}/onionrutils/blockmetadata/__init__.py (100%) rename {onionr => src}/onionrutils/blockmetadata/fromdata.py (100%) rename {onionr => src}/onionrutils/blockmetadata/hasblock.py (100%) rename {onionr => src}/onionrutils/blockmetadata/process.py (100%) rename {onionr => src}/onionrutils/bytesconverter.py (100%) rename {onionr => src}/onionrutils/checkcommunicator.py (100%) rename {onionr => src}/onionrutils/epoch.py (100%) rename {onionr => src}/onionrutils/escapeansi.py (100%) rename {onionr => src}/onionrutils/getclientapiserver.py (100%) rename {onionr => src}/onionrutils/importnewblocks.py (86%) rename {onionr => src}/onionrutils/localcommand.py (100%) rename {onionr => src}/onionrutils/mnemonickeys.py (100%) rename {onionr => src}/onionrutils/stringvalidators.py (100%) create mode 100644 src/onionrutils/updater/__init__.py rename {onionr => src}/onionrutils/validatemetadata.py (97%) rename {onionr => src}/runtests/__init__.py (100%) rename {onionr => src}/runtests/inserttest.py (100%) rename {onionr => src}/runtests/stresstest.py (100%) rename {onionr => src}/runtests/uicheck.py (100%) rename {onionr => src}/serializeddata.py (89%) rename {onionr => src}/utils/__init__.py (100%) rename {onionr => src}/utils/cachedconfig/__init__.py (100%) rename {onionr => src}/utils/createdirs.py (92%) rename {onionr => src}/utils/definewait.py (100%) rename {onionr => src}/utils/getconsolewidth.py (100%) rename {onionr => src}/utils/gethostname.py (95%) rename {onionr => src}/utils/gettransports.py (100%) rename {onionr => src}/utils/hastor.py (100%) rename {onionr => src}/utils/identifyhome.py (100%) rename {onionr => src}/utils/logoheader.py (100%) rename {onionr => src}/utils/netutils.py (100%) rename {onionr => src}/utils/networkmerger.py (100%) rename {onionr => src}/utils/readstatic.py (100%) rename {onionr => src}/utils/reconstructhash.py (100%) rename {onionr => src}/utils/safezip.py (100%) rename {onionr => src}/utils/sizeutils.py (100%) rename {onionr => src}/vanityonionr/__init__.py (100%) diff --git a/.env b/.env new file mode 100644 index 00000000..d65b3d24 --- /dev/null +++ b/.env @@ -0,0 +1 @@ +PYTHONPATH=./venv/bin/python3.7 \ No newline at end of file diff --git a/.gitignore b/.gitignore index d88ce58f..db0720a0 100755 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/make-release.sh b/make-release.sh index 36b02700..67175ebc 100755 --- a/make-release.sh +++ b/make-release.sh @@ -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 diff --git a/onionr.sh b/onionr.sh index 461da32a..0b7d898c 100755 --- a/onionr.sh +++ b/onionr.sh @@ -2,5 +2,5 @@ ORIG_ONIONR_RUN_DIR=`pwd` export ORIG_ONIONR_RUN_DIR cd "$(dirname "$0")" -cd onionr +cd src ./__init__.py "$@" \ No newline at end of file diff --git a/onionr/etc/cleanup/__init__.py b/onionr/etc/cleanup/__init__.py deleted file mode 100644 index cd4a9474..00000000 --- a/onionr/etc/cleanup/__init__.py +++ /dev/null @@ -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) diff --git a/run-windows-dev.bat b/run-windows-dev.bat index 2fbae3d7..eeed5e9c 100755 --- a/run-windows-dev.bat +++ b/run-windows-dev.bat @@ -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 %* diff --git a/run-windows.bat b/run-windows.bat index 0e209ba0..71afd897 100755 --- a/run-windows.bat +++ b/run-windows.bat @@ -1,4 +1,4 @@ @echo off setlocal -chdir onionr +chdir src python __init__.py %* diff --git a/onionr/__init__.py b/src/__init__.py similarity index 74% rename from onionr/__init__.py rename to src/__init__.py index a48d6fd2..b0b2f889 100755 --- a/onionr/__init__.py +++ b/src/__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 diff --git a/onionr/apiservers/README.md b/src/apiservers/README.md similarity index 100% rename from onionr/apiservers/README.md rename to src/apiservers/README.md diff --git a/onionr/apiservers/__init__.py b/src/apiservers/__init__.py similarity index 100% rename from onionr/apiservers/__init__.py rename to src/apiservers/__init__.py diff --git a/onionr/apiservers/private/README.md b/src/apiservers/private/README.md similarity index 100% rename from onionr/apiservers/private/README.md rename to src/apiservers/private/README.md diff --git a/onionr/apiservers/private/__init__.py b/src/apiservers/private/__init__.py similarity index 100% rename from onionr/apiservers/private/__init__.py rename to src/apiservers/private/__init__.py diff --git a/onionr/apiservers/private/register_private_blueprints.py b/src/apiservers/private/register_private_blueprints.py similarity index 100% rename from onionr/apiservers/private/register_private_blueprints.py rename to src/apiservers/private/register_private_blueprints.py diff --git a/onionr/apiservers/public/__init__.py b/src/apiservers/public/__init__.py similarity index 100% rename from onionr/apiservers/public/__init__.py rename to src/apiservers/public/__init__.py diff --git a/onionr/communicator/README.md b/src/communicator/README.md similarity index 100% rename from onionr/communicator/README.md rename to src/communicator/README.md diff --git a/onionr/communicator/__init__.py b/src/communicator/__init__.py similarity index 100% rename from onionr/communicator/__init__.py rename to src/communicator/__init__.py diff --git a/onionr/communicator/bootstrappeers.py b/src/communicator/bootstrappeers.py similarity index 100% rename from onionr/communicator/bootstrappeers.py rename to src/communicator/bootstrappeers.py diff --git a/onionr/communicator/onlinepeers/README.md b/src/communicator/onlinepeers/README.md similarity index 100% rename from onionr/communicator/onlinepeers/README.md rename to src/communicator/onlinepeers/README.md diff --git a/onionr/communicator/onlinepeers/__init__.py b/src/communicator/onlinepeers/__init__.py similarity index 100% rename from onionr/communicator/onlinepeers/__init__.py rename to src/communicator/onlinepeers/__init__.py diff --git a/onionr/communicator/onlinepeers/clearofflinepeer.py b/src/communicator/onlinepeers/clearofflinepeer.py similarity index 100% rename from onionr/communicator/onlinepeers/clearofflinepeer.py rename to src/communicator/onlinepeers/clearofflinepeer.py diff --git a/onionr/communicator/onlinepeers/onlinepeers.py b/src/communicator/onlinepeers/onlinepeers.py similarity index 100% rename from onionr/communicator/onlinepeers/onlinepeers.py rename to src/communicator/onlinepeers/onlinepeers.py diff --git a/onionr/communicator/onlinepeers/pickonlinepeers.py b/src/communicator/onlinepeers/pickonlinepeers.py similarity index 100% rename from onionr/communicator/onlinepeers/pickonlinepeers.py rename to src/communicator/onlinepeers/pickonlinepeers.py diff --git a/onionr/communicator/onlinepeers/removeonlinepeer.py b/src/communicator/onlinepeers/removeonlinepeer.py similarity index 100% rename from onionr/communicator/onlinepeers/removeonlinepeer.py rename to src/communicator/onlinepeers/removeonlinepeer.py diff --git a/onionr/communicator/peeraction.py b/src/communicator/peeraction.py similarity index 100% rename from onionr/communicator/peeraction.py rename to src/communicator/peeraction.py diff --git a/onionr/communicator/uploadqueue/__init__.py b/src/communicator/uploadqueue/__init__.py similarity index 100% rename from onionr/communicator/uploadqueue/__init__.py rename to src/communicator/uploadqueue/__init__.py diff --git a/onionr/communicatorutils/README.md b/src/communicatorutils/README.md similarity index 100% rename from onionr/communicatorutils/README.md rename to src/communicatorutils/README.md diff --git a/onionr/communicatorutils/__init__.py b/src/communicatorutils/__init__.py similarity index 100% rename from onionr/communicatorutils/__init__.py rename to src/communicatorutils/__init__.py diff --git a/onionr/communicatorutils/announcenode.py b/src/communicatorutils/announcenode.py similarity index 100% rename from onionr/communicatorutils/announcenode.py rename to src/communicatorutils/announcenode.py diff --git a/onionr/communicatorutils/connectnewpeers.py b/src/communicatorutils/connectnewpeers.py similarity index 100% rename from onionr/communicatorutils/connectnewpeers.py rename to src/communicatorutils/connectnewpeers.py diff --git a/onionr/communicatorutils/cooldownpeer.py b/src/communicatorutils/cooldownpeer.py similarity index 100% rename from onionr/communicatorutils/cooldownpeer.py rename to src/communicatorutils/cooldownpeer.py diff --git a/onionr/communicatorutils/daemonqueuehandler.py b/src/communicatorutils/daemonqueuehandler.py similarity index 100% rename from onionr/communicatorutils/daemonqueuehandler.py rename to src/communicatorutils/daemonqueuehandler.py diff --git a/onionr/communicatorutils/deniableinserts.py b/src/communicatorutils/deniableinserts.py similarity index 100% rename from onionr/communicatorutils/deniableinserts.py rename to src/communicatorutils/deniableinserts.py diff --git a/onionr/communicatorutils/downloadblocks/__init__.py b/src/communicatorutils/downloadblocks/__init__.py similarity index 100% rename from onionr/communicatorutils/downloadblocks/__init__.py rename to src/communicatorutils/downloadblocks/__init__.py diff --git a/onionr/communicatorutils/downloadblocks/shoulddownload.py b/src/communicatorutils/downloadblocks/shoulddownload.py similarity index 100% rename from onionr/communicatorutils/downloadblocks/shoulddownload.py rename to src/communicatorutils/downloadblocks/shoulddownload.py diff --git a/onionr/communicatorutils/housekeeping.py b/src/communicatorutils/housekeeping.py similarity index 100% rename from onionr/communicatorutils/housekeeping.py rename to src/communicatorutils/housekeeping.py diff --git a/onionr/communicatorutils/lookupadders.py b/src/communicatorutils/lookupadders.py similarity index 100% rename from onionr/communicatorutils/lookupadders.py rename to src/communicatorutils/lookupadders.py diff --git a/onionr/communicatorutils/lookupblocks.py b/src/communicatorutils/lookupblocks.py similarity index 100% rename from onionr/communicatorutils/lookupblocks.py rename to src/communicatorutils/lookupblocks.py diff --git a/onionr/communicatorutils/netcheck.py b/src/communicatorutils/netcheck.py similarity index 100% rename from onionr/communicatorutils/netcheck.py rename to src/communicatorutils/netcheck.py diff --git a/onionr/communicatorutils/onionrcommunicatortimers.py b/src/communicatorutils/onionrcommunicatortimers.py similarity index 100% rename from onionr/communicatorutils/onionrcommunicatortimers.py rename to src/communicatorutils/onionrcommunicatortimers.py diff --git a/onionr/communicatorutils/proxypicker.py b/src/communicatorutils/proxypicker.py similarity index 100% rename from onionr/communicatorutils/proxypicker.py rename to src/communicatorutils/proxypicker.py diff --git a/onionr/communicatorutils/restarttor.py b/src/communicatorutils/restarttor.py similarity index 100% rename from onionr/communicatorutils/restarttor.py rename to src/communicatorutils/restarttor.py diff --git a/onionr/communicatorutils/servicecreator.py b/src/communicatorutils/servicecreator.py similarity index 100% rename from onionr/communicatorutils/servicecreator.py rename to src/communicatorutils/servicecreator.py diff --git a/onionr/communicatorutils/uploadblocks/__init__.py b/src/communicatorutils/uploadblocks/__init__.py similarity index 100% rename from onionr/communicatorutils/uploadblocks/__init__.py rename to src/communicatorutils/uploadblocks/__init__.py diff --git a/onionr/communicatorutils/uploadblocks/session.py b/src/communicatorutils/uploadblocks/session.py similarity index 100% rename from onionr/communicatorutils/uploadblocks/session.py rename to src/communicatorutils/uploadblocks/session.py diff --git a/onionr/communicatorutils/uploadblocks/sessionmanager.py b/src/communicatorutils/uploadblocks/sessionmanager.py similarity index 100% rename from onionr/communicatorutils/uploadblocks/sessionmanager.py rename to src/communicatorutils/uploadblocks/sessionmanager.py diff --git a/onionr/config.py b/src/config.py similarity index 100% rename from onionr/config.py rename to src/config.py diff --git a/onionr/coredb/__init__.py b/src/coredb/__init__.py similarity index 100% rename from onionr/coredb/__init__.py rename to src/coredb/__init__.py diff --git a/onionr/coredb/blockmetadb/__init__.py b/src/coredb/blockmetadb/__init__.py similarity index 100% rename from onionr/coredb/blockmetadb/__init__.py rename to src/coredb/blockmetadb/__init__.py diff --git a/onionr/coredb/blockmetadb/add.py b/src/coredb/blockmetadb/add.py similarity index 100% rename from onionr/coredb/blockmetadb/add.py rename to src/coredb/blockmetadb/add.py diff --git a/onionr/coredb/blockmetadb/expiredblocks.py b/src/coredb/blockmetadb/expiredblocks.py similarity index 100% rename from onionr/coredb/blockmetadb/expiredblocks.py rename to src/coredb/blockmetadb/expiredblocks.py diff --git a/onionr/coredb/blockmetadb/updateblockinfo.py b/src/coredb/blockmetadb/updateblockinfo.py similarity index 100% rename from onionr/coredb/blockmetadb/updateblockinfo.py rename to src/coredb/blockmetadb/updateblockinfo.py diff --git a/onionr/coredb/daemonqueue/__init__.py b/src/coredb/daemonqueue/__init__.py similarity index 100% rename from onionr/coredb/daemonqueue/__init__.py rename to src/coredb/daemonqueue/__init__.py diff --git a/onionr/coredb/dbfiles.py b/src/coredb/dbfiles.py similarity index 100% rename from onionr/coredb/dbfiles.py rename to src/coredb/dbfiles.py diff --git a/onionr/coredb/keydb/__init__.py b/src/coredb/keydb/__init__.py similarity index 100% rename from onionr/coredb/keydb/__init__.py rename to src/coredb/keydb/__init__.py diff --git a/onionr/coredb/keydb/addkeys.py b/src/coredb/keydb/addkeys.py similarity index 100% rename from onionr/coredb/keydb/addkeys.py rename to src/coredb/keydb/addkeys.py diff --git a/onionr/coredb/keydb/listkeys.py b/src/coredb/keydb/listkeys.py similarity index 100% rename from onionr/coredb/keydb/listkeys.py rename to src/coredb/keydb/listkeys.py diff --git a/onionr/coredb/keydb/removekeys.py b/src/coredb/keydb/removekeys.py similarity index 100% rename from onionr/coredb/keydb/removekeys.py rename to src/coredb/keydb/removekeys.py diff --git a/onionr/coredb/keydb/transportinfo.py b/src/coredb/keydb/transportinfo.py similarity index 100% rename from onionr/coredb/keydb/transportinfo.py rename to src/coredb/keydb/transportinfo.py diff --git a/onionr/coredb/keydb/userinfo.py b/src/coredb/keydb/userinfo.py similarity index 100% rename from onionr/coredb/keydb/userinfo.py rename to src/coredb/keydb/userinfo.py diff --git a/onionr/etc/README.md b/src/etc/README.md similarity index 100% rename from onionr/etc/README.md rename to src/etc/README.md diff --git a/onionr/etc/__init__.py b/src/etc/__init__.py similarity index 100% rename from onionr/etc/__init__.py rename to src/etc/__init__.py diff --git a/onionr/onionrutils/updater/__init__.py b/src/etc/cleanup/__init__.py similarity index 58% rename from onionr/onionrutils/updater/__init__.py rename to src/etc/cleanup/__init__.py index c3db94f3..1a5b651b 100644 --- a/onionr/onionrutils/updater/__init__.py +++ b/src/etc/cleanup/__init__.py @@ -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 . """ -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) diff --git a/src/etc/dependencycheck.py b/src/etc/dependencycheck.py new file mode 100644 index 00000000..6b83ebc2 --- /dev/null +++ b/src/etc/dependencycheck.py @@ -0,0 +1 @@ +from urllib3.contrib.socks import SOCKSProxyManager # noqa \ No newline at end of file diff --git a/onionr/etc/humanreadabletime.py b/src/etc/humanreadabletime.py similarity index 100% rename from onionr/etc/humanreadabletime.py rename to src/etc/humanreadabletime.py diff --git a/onionr/etc/onionrvalues.py b/src/etc/onionrvalues.py similarity index 100% rename from onionr/etc/onionrvalues.py rename to src/etc/onionrvalues.py diff --git a/onionr/etc/powchoice.py b/src/etc/powchoice.py similarity index 100% rename from onionr/etc/powchoice.py rename to src/etc/powchoice.py diff --git a/onionr/etc/waitforsetvar.py b/src/etc/waitforsetvar.py similarity index 100% rename from onionr/etc/waitforsetvar.py rename to src/etc/waitforsetvar.py diff --git a/onionr/filepaths/__init__.py b/src/filepaths/__init__.py similarity index 100% rename from onionr/filepaths/__init__.py rename to src/filepaths/__init__.py diff --git a/onionr/httpapi/README.md b/src/httpapi/README.md similarity index 100% rename from onionr/httpapi/README.md rename to src/httpapi/README.md diff --git a/onionr/httpapi/__init__.py b/src/httpapi/__init__.py similarity index 100% rename from onionr/httpapi/__init__.py rename to src/httpapi/__init__.py diff --git a/onionr/httpapi/apiutils/__init__.py b/src/httpapi/apiutils/__init__.py similarity index 100% rename from onionr/httpapi/apiutils/__init__.py rename to src/httpapi/apiutils/__init__.py diff --git a/onionr/httpapi/apiutils/getblockdata.py b/src/httpapi/apiutils/getblockdata.py similarity index 100% rename from onionr/httpapi/apiutils/getblockdata.py rename to src/httpapi/apiutils/getblockdata.py diff --git a/onionr/httpapi/apiutils/setbindip.py b/src/httpapi/apiutils/setbindip.py similarity index 100% rename from onionr/httpapi/apiutils/setbindip.py rename to src/httpapi/apiutils/setbindip.py diff --git a/onionr/httpapi/apiutils/shutdown.py b/src/httpapi/apiutils/shutdown.py similarity index 100% rename from onionr/httpapi/apiutils/shutdown.py rename to src/httpapi/apiutils/shutdown.py diff --git a/onionr/httpapi/configapi/__init__.py b/src/httpapi/configapi/__init__.py similarity index 100% rename from onionr/httpapi/configapi/__init__.py rename to src/httpapi/configapi/__init__.py diff --git a/onionr/httpapi/directconnections/__init__.py b/src/httpapi/directconnections/__init__.py similarity index 100% rename from onionr/httpapi/directconnections/__init__.py rename to src/httpapi/directconnections/__init__.py diff --git a/onionr/httpapi/fdsafehandler.py b/src/httpapi/fdsafehandler.py similarity index 100% rename from onionr/httpapi/fdsafehandler.py rename to src/httpapi/fdsafehandler.py diff --git a/onionr/httpapi/friendsapi/__init__.py b/src/httpapi/friendsapi/__init__.py similarity index 100% rename from onionr/httpapi/friendsapi/__init__.py rename to src/httpapi/friendsapi/__init__.py diff --git a/onionr/httpapi/insertblock.py b/src/httpapi/insertblock.py similarity index 100% rename from onionr/httpapi/insertblock.py rename to src/httpapi/insertblock.py diff --git a/onionr/httpapi/miscclientapi/__init__.py b/src/httpapi/miscclientapi/__init__.py similarity index 100% rename from onionr/httpapi/miscclientapi/__init__.py rename to src/httpapi/miscclientapi/__init__.py diff --git a/onionr/httpapi/miscclientapi/endpoints.py b/src/httpapi/miscclientapi/endpoints.py similarity index 100% rename from onionr/httpapi/miscclientapi/endpoints.py rename to src/httpapi/miscclientapi/endpoints.py diff --git a/onionr/httpapi/miscclientapi/getblocks.py b/src/httpapi/miscclientapi/getblocks.py similarity index 100% rename from onionr/httpapi/miscclientapi/getblocks.py rename to src/httpapi/miscclientapi/getblocks.py diff --git a/onionr/httpapi/miscclientapi/motd/__init__.py b/src/httpapi/miscclientapi/motd/__init__.py similarity index 100% rename from onionr/httpapi/miscclientapi/motd/__init__.py rename to src/httpapi/miscclientapi/motd/__init__.py diff --git a/onionr/httpapi/miscclientapi/staticfiles.py b/src/httpapi/miscclientapi/staticfiles.py similarity index 100% rename from onionr/httpapi/miscclientapi/staticfiles.py rename to src/httpapi/miscclientapi/staticfiles.py diff --git a/onionr/httpapi/miscpublicapi/__init__.py b/src/httpapi/miscpublicapi/__init__.py similarity index 100% rename from onionr/httpapi/miscpublicapi/__init__.py rename to src/httpapi/miscpublicapi/__init__.py diff --git a/onionr/httpapi/miscpublicapi/announce.py b/src/httpapi/miscpublicapi/announce.py similarity index 100% rename from onionr/httpapi/miscpublicapi/announce.py rename to src/httpapi/miscpublicapi/announce.py diff --git a/onionr/httpapi/miscpublicapi/endpoints.py b/src/httpapi/miscpublicapi/endpoints.py similarity index 100% rename from onionr/httpapi/miscpublicapi/endpoints.py rename to src/httpapi/miscpublicapi/endpoints.py diff --git a/onionr/httpapi/miscpublicapi/getblocks.py b/src/httpapi/miscpublicapi/getblocks.py similarity index 100% rename from onionr/httpapi/miscpublicapi/getblocks.py rename to src/httpapi/miscpublicapi/getblocks.py diff --git a/onionr/httpapi/miscpublicapi/upload.py b/src/httpapi/miscpublicapi/upload.py similarity index 100% rename from onionr/httpapi/miscpublicapi/upload.py rename to src/httpapi/miscpublicapi/upload.py diff --git a/onionr/httpapi/onionrsitesapi/__init__.py b/src/httpapi/onionrsitesapi/__init__.py similarity index 100% rename from onionr/httpapi/onionrsitesapi/__init__.py rename to src/httpapi/onionrsitesapi/__init__.py diff --git a/onionr/httpapi/onionrsitesapi/findsite.py b/src/httpapi/onionrsitesapi/findsite.py similarity index 70% rename from onionr/httpapi/onionrsitesapi/findsite.py rename to src/httpapi/onionrsitesapi/findsite.py index 77e5e484..28c2f4db 100644 --- a/onionr/httpapi/onionrsitesapi/findsite.py +++ b/src/httpapi/onionrsitesapi/findsite.py @@ -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 . """ -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(): diff --git a/onionr/httpapi/onionrsitesapi/sitefiles.py b/src/httpapi/onionrsitesapi/sitefiles.py similarity index 100% rename from onionr/httpapi/onionrsitesapi/sitefiles.py rename to src/httpapi/onionrsitesapi/sitefiles.py diff --git a/onionr/httpapi/profilesapi/__init__.py b/src/httpapi/profilesapi/__init__.py similarity index 100% rename from onionr/httpapi/profilesapi/__init__.py rename to src/httpapi/profilesapi/__init__.py diff --git a/onionr/httpapi/profilesapi/profiles.py b/src/httpapi/profilesapi/profiles.py similarity index 100% rename from onionr/httpapi/profilesapi/profiles.py rename to src/httpapi/profilesapi/profiles.py diff --git a/onionr/httpapi/security/__init__.py b/src/httpapi/security/__init__.py similarity index 100% rename from onionr/httpapi/security/__init__.py rename to src/httpapi/security/__init__.py diff --git a/onionr/httpapi/security/client.py b/src/httpapi/security/client.py similarity index 100% rename from onionr/httpapi/security/client.py rename to src/httpapi/security/client.py diff --git a/onionr/httpapi/security/pluginwhitelist.py b/src/httpapi/security/pluginwhitelist.py similarity index 100% rename from onionr/httpapi/security/pluginwhitelist.py rename to src/httpapi/security/pluginwhitelist.py diff --git a/onionr/httpapi/security/public.py b/src/httpapi/security/public.py similarity index 100% rename from onionr/httpapi/security/public.py rename to src/httpapi/security/public.py diff --git a/onionr/httpapi/themeapi/__init__.py b/src/httpapi/themeapi/__init__.py similarity index 100% rename from onionr/httpapi/themeapi/__init__.py rename to src/httpapi/themeapi/__init__.py diff --git a/onionr/keymanager.py b/src/keymanager.py similarity index 100% rename from onionr/keymanager.py rename to src/keymanager.py diff --git a/onionr/logger/__init__.py b/src/logger/__init__.py similarity index 100% rename from onionr/logger/__init__.py rename to src/logger/__init__.py diff --git a/onionr/logger/colors.py b/src/logger/colors.py similarity index 100% rename from onionr/logger/colors.py rename to src/logger/colors.py diff --git a/onionr/logger/confirm.py b/src/logger/confirm.py similarity index 100% rename from onionr/logger/confirm.py rename to src/logger/confirm.py diff --git a/onionr/logger/log.py b/src/logger/log.py similarity index 100% rename from onionr/logger/log.py rename to src/logger/log.py diff --git a/onionr/logger/raw.py b/src/logger/raw.py similarity index 100% rename from onionr/logger/raw.py rename to src/logger/raw.py diff --git a/onionr/logger/readline.py b/src/logger/readline.py similarity index 100% rename from onionr/logger/readline.py rename to src/logger/readline.py diff --git a/onionr/logger/settings.py b/src/logger/settings.py similarity index 100% rename from onionr/logger/settings.py rename to src/logger/settings.py diff --git a/onionr/netcontroller/__init__.py b/src/netcontroller/__init__.py similarity index 100% rename from onionr/netcontroller/__init__.py rename to src/netcontroller/__init__.py diff --git a/onionr/netcontroller/getopenport.py b/src/netcontroller/getopenport.py similarity index 100% rename from onionr/netcontroller/getopenport.py rename to src/netcontroller/getopenport.py diff --git a/onionr/netcontroller/netcontrol.py b/src/netcontroller/netcontrol.py similarity index 100% rename from onionr/netcontroller/netcontrol.py rename to src/netcontroller/netcontrol.py diff --git a/onionr/netcontroller/rebuildtor.py b/src/netcontroller/rebuildtor.py similarity index 100% rename from onionr/netcontroller/rebuildtor.py rename to src/netcontroller/rebuildtor.py diff --git a/onionr/netcontroller/torbinary.py b/src/netcontroller/torbinary.py similarity index 100% rename from onionr/netcontroller/torbinary.py rename to src/netcontroller/torbinary.py diff --git a/onionr/netcontroller/torcontroller.py b/src/netcontroller/torcontroller.py similarity index 100% rename from onionr/netcontroller/torcontroller.py rename to src/netcontroller/torcontroller.py diff --git a/onionr/notifier/__init__.py b/src/notifier/__init__.py similarity index 100% rename from onionr/notifier/__init__.py rename to src/notifier/__init__.py diff --git a/onionr/onionrblocks/__init__.py b/src/onionrblocks/__init__.py similarity index 100% rename from onionr/onionrblocks/__init__.py rename to src/onionrblocks/__init__.py diff --git a/onionr/onionrblocks/blockimporter.py b/src/onionrblocks/blockimporter.py similarity index 100% rename from onionr/onionrblocks/blockimporter.py rename to src/onionrblocks/blockimporter.py diff --git a/onionr/onionrblocks/insert.py b/src/onionrblocks/insert.py similarity index 98% rename from onionr/onionrblocks/insert.py rename to src/onionrblocks/insert.py index cb9e050c..a444eeb2 100644 --- a/onionr/onionrblocks/insert.py +++ b/src/onionrblocks/insert.py @@ -53,6 +53,7 @@ def insert_block(data: Union[str, bytes], header: str ='txt', use_subprocess = powchoice.use_subprocess(config) storage_counter = storagecounter.StorageCounter() + allocationReachedMessage = 'Cannot insert block, disk allocation reached.' if storage_counter.is_full(): logger.error(allocationReachedMessage) @@ -181,7 +182,8 @@ def insert_block(data: Union[str, bytes], header: str ='txt', coredb.blockmetadb.add.add_to_block_DB(retData, selfInsert=True, dataSaved=True) if expire is None: - coredb.blockmetadb.update_block_info(retData, 'expire', createTime + onionrvalues.DEFAULT_EXPIRE) + coredb.blockmetadb.update_block_info(retData, 'expire', + createTime + onionrvalues.DEFAULT_EXPIRE) else: coredb.blockmetadb.update_block_info(retData, 'expire', expire) diff --git a/onionr/onionrblocks/onionrblacklist.py b/src/onionrblocks/onionrblacklist.py similarity index 100% rename from onionr/onionrblocks/onionrblacklist.py rename to src/onionrblocks/onionrblacklist.py diff --git a/onionr/onionrblocks/onionrblockapi.py b/src/onionrblocks/onionrblockapi.py similarity index 100% rename from onionr/onionrblocks/onionrblockapi.py rename to src/onionrblocks/onionrblockapi.py diff --git a/onionr/onionrblocks/storagecounter.py b/src/onionrblocks/storagecounter.py similarity index 100% rename from onionr/onionrblocks/storagecounter.py rename to src/onionrblocks/storagecounter.py diff --git a/onionr/onionrcommands/README.md b/src/onionrcommands/README.md similarity index 100% rename from onionr/onionrcommands/README.md rename to src/onionrcommands/README.md diff --git a/onionr/onionrcommands/__init__.py b/src/onionrcommands/__init__.py similarity index 100% rename from onionr/onionrcommands/__init__.py rename to src/onionrcommands/__init__.py diff --git a/onionr/onionrcommands/banblocks.py b/src/onionrcommands/banblocks.py similarity index 100% rename from onionr/onionrcommands/banblocks.py rename to src/onionrcommands/banblocks.py diff --git a/onionr/onionrcommands/daemonlaunch.py b/src/onionrcommands/daemonlaunch.py similarity index 100% rename from onionr/onionrcommands/daemonlaunch.py rename to src/onionrcommands/daemonlaunch.py diff --git a/onionr/onionrcommands/exportblocks.py b/src/onionrcommands/exportblocks.py similarity index 100% rename from onionr/onionrcommands/exportblocks.py rename to src/onionrcommands/exportblocks.py diff --git a/onionr/onionrcommands/filecommands.py b/src/onionrcommands/filecommands.py similarity index 100% rename from onionr/onionrcommands/filecommands.py rename to src/onionrcommands/filecommands.py diff --git a/onionr/onionrcommands/keyadders.py b/src/onionrcommands/keyadders.py similarity index 100% rename from onionr/onionrcommands/keyadders.py rename to src/onionrcommands/keyadders.py diff --git a/onionr/onionrcommands/motdcreator.py b/src/onionrcommands/motdcreator.py similarity index 100% rename from onionr/onionrcommands/motdcreator.py rename to src/onionrcommands/motdcreator.py diff --git a/onionr/onionrcommands/onionrstatistics.py b/src/onionrcommands/onionrstatistics.py similarity index 100% rename from onionr/onionrcommands/onionrstatistics.py rename to src/onionrcommands/onionrstatistics.py diff --git a/onionr/onionrcommands/openwebinterface.py b/src/onionrcommands/openwebinterface.py similarity index 100% rename from onionr/onionrcommands/openwebinterface.py rename to src/onionrcommands/openwebinterface.py diff --git a/onionr/onionrcommands/parser/__init__.py b/src/onionrcommands/parser/__init__.py similarity index 97% rename from onionr/onionrcommands/parser/__init__.py rename to src/onionrcommands/parser/__init__.py index 1d45cca2..cc99ebb9 100644 --- a/onionr/onionrcommands/parser/__init__.py +++ b/src/onionrcommands/parser/__init__.py @@ -72,7 +72,7 @@ def register(): try: try: - if cmd != 'start': os.chdir(os.environ['ORIG_ONIONR_RUN_DIR']) + if not cmd in ('start', 'details', 'show-details') : os.chdir(os.environ['ORIG_ONIONR_RUN_DIR']) except KeyError: pass try: arguments.get_func(cmd)() diff --git a/onionr/onionrcommands/parser/arguments.py b/src/onionrcommands/parser/arguments.py similarity index 100% rename from onionr/onionrcommands/parser/arguments.py rename to src/onionrcommands/parser/arguments.py diff --git a/onionr/onionrcommands/parser/recommend.py b/src/onionrcommands/parser/recommend.py similarity index 100% rename from onionr/onionrcommands/parser/recommend.py rename to src/onionrcommands/parser/recommend.py diff --git a/onionr/onionrcommands/pubkeymanager.py b/src/onionrcommands/pubkeymanager.py similarity index 100% rename from onionr/onionrcommands/pubkeymanager.py rename to src/onionrcommands/pubkeymanager.py diff --git a/onionr/onionrcommands/resetplugins.py b/src/onionrcommands/resetplugins.py similarity index 100% rename from onionr/onionrcommands/resetplugins.py rename to src/onionrcommands/resetplugins.py diff --git a/onionr/onionrcommands/resettor.py b/src/onionrcommands/resettor.py similarity index 100% rename from onionr/onionrcommands/resettor.py rename to src/onionrcommands/resettor.py diff --git a/onionr/onionrcommands/restartonionr.py b/src/onionrcommands/restartonionr.py similarity index 100% rename from onionr/onionrcommands/restartonionr.py rename to src/onionrcommands/restartonionr.py diff --git a/onionr/onionrcommands/runtimetestcmd.py b/src/onionrcommands/runtimetestcmd.py similarity index 100% rename from onionr/onionrcommands/runtimetestcmd.py rename to src/onionrcommands/runtimetestcmd.py diff --git a/onionr/onionrcommands/sitecreator.py b/src/onionrcommands/sitecreator.py similarity index 100% rename from onionr/onionrcommands/sitecreator.py rename to src/onionrcommands/sitecreator.py diff --git a/onionr/onionrcommands/softreset.py b/src/onionrcommands/softreset.py similarity index 100% rename from onionr/onionrcommands/softreset.py rename to src/onionrcommands/softreset.py diff --git a/onionr/onionrcommands/version.py b/src/onionrcommands/version.py similarity index 100% rename from onionr/onionrcommands/version.py rename to src/onionrcommands/version.py diff --git a/onionr/onionrcrypto/__init__.py b/src/onionrcrypto/__init__.py similarity index 100% rename from onionr/onionrcrypto/__init__.py rename to src/onionrcrypto/__init__.py diff --git a/onionr/onionrcrypto/cryptoutils/__init__.py b/src/onionrcrypto/cryptoutils/__init__.py similarity index 100% rename from onionr/onionrcrypto/cryptoutils/__init__.py rename to src/onionrcrypto/cryptoutils/__init__.py diff --git a/onionr/onionrcrypto/cryptoutils/getpubfrompriv.py b/src/onionrcrypto/cryptoutils/getpubfrompriv.py similarity index 100% rename from onionr/onionrcrypto/cryptoutils/getpubfrompriv.py rename to src/onionrcrypto/cryptoutils/getpubfrompriv.py diff --git a/onionr/onionrcrypto/cryptoutils/randomshuffle.py b/src/onionrcrypto/cryptoutils/randomshuffle.py similarity index 100% rename from onionr/onionrcrypto/cryptoutils/randomshuffle.py rename to src/onionrcrypto/cryptoutils/randomshuffle.py diff --git a/onionr/onionrcrypto/cryptoutils/replayvalidation.py b/src/onionrcrypto/cryptoutils/replayvalidation.py similarity index 100% rename from onionr/onionrcrypto/cryptoutils/replayvalidation.py rename to src/onionrcrypto/cryptoutils/replayvalidation.py diff --git a/onionr/onionrcrypto/cryptoutils/safecompare.py b/src/onionrcrypto/cryptoutils/safecompare.py similarity index 100% rename from onionr/onionrcrypto/cryptoutils/safecompare.py rename to src/onionrcrypto/cryptoutils/safecompare.py diff --git a/onionr/onionrcrypto/cryptoutils/verifypow.py b/src/onionrcrypto/cryptoutils/verifypow.py similarity index 100% rename from onionr/onionrcrypto/cryptoutils/verifypow.py rename to src/onionrcrypto/cryptoutils/verifypow.py diff --git a/onionr/onionrcrypto/encryption/__init__.py b/src/onionrcrypto/encryption/__init__.py similarity index 100% rename from onionr/onionrcrypto/encryption/__init__.py rename to src/onionrcrypto/encryption/__init__.py diff --git a/onionr/onionrcrypto/generate.py b/src/onionrcrypto/generate.py similarity index 100% rename from onionr/onionrcrypto/generate.py rename to src/onionrcrypto/generate.py diff --git a/onionr/onionrcrypto/getourkeypair.py b/src/onionrcrypto/getourkeypair.py similarity index 100% rename from onionr/onionrcrypto/getourkeypair.py rename to src/onionrcrypto/getourkeypair.py diff --git a/onionr/onionrcrypto/hashers.py b/src/onionrcrypto/hashers.py similarity index 100% rename from onionr/onionrcrypto/hashers.py rename to src/onionrcrypto/hashers.py diff --git a/onionr/onionrcrypto/signing/__init__.py b/src/onionrcrypto/signing/__init__.py similarity index 100% rename from onionr/onionrcrypto/signing/__init__.py rename to src/onionrcrypto/signing/__init__.py diff --git a/onionr/onionrexceptions.py b/src/onionrexceptions.py similarity index 100% rename from onionr/onionrexceptions.py rename to src/onionrexceptions.py diff --git a/onionr/onionrpeers/__init__.py b/src/onionrpeers/__init__.py similarity index 100% rename from onionr/onionrpeers/__init__.py rename to src/onionrpeers/__init__.py diff --git a/onionr/onionrpeers/peercleanup.py b/src/onionrpeers/peercleanup.py similarity index 100% rename from onionr/onionrpeers/peercleanup.py rename to src/onionrpeers/peercleanup.py diff --git a/onionr/onionrpeers/peerprofiles.py b/src/onionrpeers/peerprofiles.py similarity index 100% rename from onionr/onionrpeers/peerprofiles.py rename to src/onionrpeers/peerprofiles.py diff --git a/onionr/onionrpeers/scoresortedpeerlist.py b/src/onionrpeers/scoresortedpeerlist.py similarity index 100% rename from onionr/onionrpeers/scoresortedpeerlist.py rename to src/onionrpeers/scoresortedpeerlist.py diff --git a/onionr/onionrplugins/__init__.py b/src/onionrplugins/__init__.py similarity index 100% rename from onionr/onionrplugins/__init__.py rename to src/onionrplugins/__init__.py diff --git a/onionr/onionrplugins/onionrevents.py b/src/onionrplugins/onionrevents.py similarity index 100% rename from onionr/onionrplugins/onionrevents.py rename to src/onionrplugins/onionrevents.py diff --git a/onionr/onionrplugins/onionrpluginapi.py b/src/onionrplugins/onionrpluginapi.py similarity index 100% rename from onionr/onionrplugins/onionrpluginapi.py rename to src/onionrplugins/onionrpluginapi.py diff --git a/onionr/onionrproofs/__init__.py b/src/onionrproofs/__init__.py similarity index 100% rename from onionr/onionrproofs/__init__.py rename to src/onionrproofs/__init__.py diff --git a/onionr/onionrproofs/subprocesspow.py b/src/onionrproofs/subprocesspow.py similarity index 70% rename from onionr/onionrproofs/subprocesspow.py rename to src/onionrproofs/subprocesspow.py index 37936b74..472e85ad 100755 --- a/onionr/onionrproofs/subprocesspow.py +++ b/src/onionrproofs/subprocesspow.py @@ -1,10 +1,22 @@ #!/usr/bin/env python3 -''' +""" Onionr - Private P2P Communication Multiprocess proof of work -''' -''' +""" + +import os +from multiprocessing import Pipe, Process +import threading +import time +import json + +import logger +import onionrproofs +import onionrcrypto as crypto +from onionrutils import bytesconverter + +""" 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 @@ -17,23 +29,20 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . -''' +""" + -import subprocess, os -import multiprocessing, threading, time, json -from multiprocessing import Pipe, Process -from onionrblocks import onionrblockapi -import config, onionrutils, logger, onionrproofs, onionrcrypto as crypto -from onionrutils import bytesconverter class SubprocessPOW: def __init__(self, data, metadata, subproc_count=None): - ''' + """ Onionr proof of work using multiple processes Accepts block data, block metadata - if subproc_count is not set, os.cpu_count() is used to determine the number of processes + if subproc_count is not set, + os.cpu_count() is used to determine the number of processes - Do to Python GIL multiprocessing or use of external libraries is necessary to accelerate CPU bound tasks - ''' + Due to Python GIL multiprocessing/use of external libraries + is necessary to accelerate CPU bound tasks + """ # No known benefit to using more processes than there are cores. # Note: os.cpu_count perhaps not always accurate if subproc_count is None: @@ -44,23 +53,30 @@ class SubprocessPOW: self.data = data self.metadata = metadata - # dump dict to measure bytes of json metadata. Cannot reuse later because the pow token must be added + """dump dict to measure bytes of json metadata + Cannot reuse later bc the pow token must be added + """ json_metadata = json.dumps(metadata).encode() self.data = bytesconverter.str_to_bytes(data) - # Calculate difficulty. Dumb for now, may use good algorithm in the future. - self.difficulty = onionrproofs.getDifficultyForNewBlock(bytes(json_metadata + b'\n' + self.data)) - + + compiled_data = bytes(json_metadata + b'\n' + self.data) + + # Calculate difficulty. May use better algorithm in the future. + self.difficulty = onionrproofs.getDifficultyForNewBlock(compiled_data) + logger.info('Computing POW (difficulty: %s)...' % (self.difficulty,)) - self.mainHash = '0' * 64 - self.puzzle = self.mainHash[0:min(self.difficulty, len(self.mainHash))] + self.main_hash = '0' * 64 + self.puzzle = self.main_hash[0:min(self.difficulty, + len(self.main_hash))] self.shutdown = False self.payload = None def start(self): + """spawn the multiproc handler threads""" # Create a new thread for each subprocess - for x in range(self.subproc_count): + for _ in range(self.subproc_count): # noqa threading.Thread(target=self._spawn_proc).start() # Monitor the processes for a payload, shut them down when its found while True: @@ -69,9 +85,10 @@ class SubprocessPOW: else: self.shutdown = True return self.payload - + def _spawn_proc(self): - # Create a child proof of work process, wait for data and send shutdown signal when its found + """Create a child proof of work process + wait for data and send shutdown signal when its found""" parent_conn, child_conn = Pipe() p = Process(target=self.do_pow, args=(child_conn,)) p.start() @@ -90,8 +107,8 @@ class SubprocessPOW: self.payload = payload def do_pow(self, pipe): - nonce = -10000000 # Start nonce at negative 10 million so that the chosen nonce is likely to be small in length - nonceStart = nonce + """find partial hash colision generating nonce for a block""" + nonce = -10000000 data = self.data metadata = self.metadata puzzle = self.puzzle @@ -104,11 +121,12 @@ class SubprocessPOW: metadata['pow'] = nonce # Serialize metadata, combine with block data payload = json.dumps(metadata).encode() + b'\n' + data - # Check sha3_256 hash of block, compare to puzzle. Send payload if puzzle finished + # Check sha3_256 hash of block, compare to puzzle + # Send payload if puzzle finished token = crypto.hashers.sha3_hash(payload) - token = bytesconverter.bytes_to_str(token) # ensure token is string + # ensure token is string + token = bytesconverter.bytes_to_str(token) if puzzle == token[0:difficulty]: pipe.send(payload) break nonce += 1 - \ No newline at end of file diff --git a/onionr/onionrservices/README.md b/src/onionrservices/README.md similarity index 100% rename from onionr/onionrservices/README.md rename to src/onionrservices/README.md diff --git a/onionr/onionrservices/__init__.py b/src/onionrservices/__init__.py similarity index 100% rename from onionr/onionrservices/__init__.py rename to src/onionrservices/__init__.py diff --git a/onionr/onionrservices/bootstrapservice.py b/src/onionrservices/bootstrapservice.py similarity index 100% rename from onionr/onionrservices/bootstrapservice.py rename to src/onionrservices/bootstrapservice.py diff --git a/onionr/onionrservices/connectionserver.py b/src/onionrservices/connectionserver.py similarity index 100% rename from onionr/onionrservices/connectionserver.py rename to src/onionrservices/connectionserver.py diff --git a/onionr/onionrservices/httpheaders.py b/src/onionrservices/httpheaders.py similarity index 100% rename from onionr/onionrservices/httpheaders.py rename to src/onionrservices/httpheaders.py diff --git a/onionr/onionrservices/pool.py b/src/onionrservices/pool.py similarity index 100% rename from onionr/onionrservices/pool.py rename to src/onionrservices/pool.py diff --git a/onionr/onionrservices/serverexists.py b/src/onionrservices/serverexists.py similarity index 100% rename from onionr/onionrservices/serverexists.py rename to src/onionrservices/serverexists.py diff --git a/onionr/onionrservices/warden/__init__.py b/src/onionrservices/warden/__init__.py similarity index 100% rename from onionr/onionrservices/warden/__init__.py rename to src/onionrservices/warden/__init__.py diff --git a/onionr/onionrservices/warden/bootstrap.py b/src/onionrservices/warden/bootstrap.py similarity index 100% rename from onionr/onionrservices/warden/bootstrap.py rename to src/onionrservices/warden/bootstrap.py diff --git a/onionr/onionrservices/warden/client.py b/src/onionrservices/warden/client.py similarity index 100% rename from onionr/onionrservices/warden/client.py rename to src/onionrservices/warden/client.py diff --git a/onionr/onionrservices/warden/server.py b/src/onionrservices/warden/server.py similarity index 100% rename from onionr/onionrservices/warden/server.py rename to src/onionrservices/warden/server.py diff --git a/onionr/onionrsetup/__init__.py b/src/onionrsetup/__init__.py similarity index 100% rename from onionr/onionrsetup/__init__.py rename to src/onionrsetup/__init__.py diff --git a/onionr/onionrsetup/dbcreator.py b/src/onionrsetup/dbcreator.py similarity index 100% rename from onionr/onionrsetup/dbcreator.py rename to src/onionrsetup/dbcreator.py diff --git a/onionr/onionrsetup/defaultpluginsetup.py b/src/onionrsetup/defaultpluginsetup.py similarity index 100% rename from onionr/onionrsetup/defaultpluginsetup.py rename to src/onionrsetup/defaultpluginsetup.py diff --git a/onionr/onionrsetup/setupconfig.py b/src/onionrsetup/setupconfig.py similarity index 100% rename from onionr/onionrsetup/setupconfig.py rename to src/onionrsetup/setupconfig.py diff --git a/onionr/onionrstorage/__init__.py b/src/onionrstorage/__init__.py similarity index 85% rename from onionr/onionrstorage/__init__.py rename to src/onionrstorage/__init__.py index c65787fb..636db538 100755 --- a/onionr/onionrstorage/__init__.py +++ b/src/onionrstorage/__init__.py @@ -3,6 +3,18 @@ This file handles block storage, providing an abstraction for storing blocks between file system and database ''' +import sys +import sqlite3 +import os +from onionrutils import bytesconverter +from onionrutils import stringvalidators +from coredb import dbfiles +import filepaths +import onionrcrypto +import onionrexceptions +from onionrsetup import dbcreator +from onionrcrypto import hashers +from . import setdata ''' 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,17 +29,13 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . ''' -import sys, sqlite3, os -from onionrutils import bytesconverter, stringvalidators -from coredb import dbfiles -import filepaths, onionrcrypto, onionrexceptions -from onionrsetup import dbcreator -from onionrcrypto import hashers -from . import setdata -DB_ENTRY_SIZE_LIMIT = 10000 # Will be a config option + + +DB_ENTRY_SIZE_LIMIT = 10000 # Will be a config option set_data = setdata.set_data + def _dbInsert(blockHash, data): conn = sqlite3.connect(dbfiles.block_data_db, timeout=10) c = conn.cursor() @@ -36,6 +44,7 @@ def _dbInsert(blockHash, data): conn.commit() conn.close() + def _dbFetch(blockHash): conn = sqlite3.connect(dbfiles.block_data_db, timeout=10) c = conn.cursor() @@ -45,6 +54,7 @@ def _dbFetch(blockHash): conn.close() return None + def deleteBlock(blockHash): # You should call removeblock.remove_block if you automatically want to remove storage byte count if os.path.exists('%s/%s.dat' % (filepaths.block_data_location, blockHash)): @@ -58,11 +68,13 @@ def deleteBlock(blockHash): conn.close() return True + def store(data, blockHash=''): if not stringvalidators.validate_hash(blockHash): raise ValueError ourHash = hashers.sha3_hash(data) if blockHash != '': - if not ourHash == blockHash: raise ValueError('Hash specified does not meet internal hash check') + if not ourHash == blockHash: + raise ValueError('Hash specified does not meet internal hash check') else: blockHash = ourHash @@ -72,6 +84,7 @@ def store(data, blockHash=''): with open('%s/%s.dat' % (filepaths.block_data_location, blockHash), 'wb') as blockFile: blockFile.write(data) + def getData(bHash): if not stringvalidators.validate_hash(bHash): raise ValueError @@ -82,11 +95,12 @@ def getData(bHash): # If no entry in either, raise an exception retData = None fileLocation = '%s/%s.dat' % (filepaths.block_data_location, bHash) + not_found_msg = "Flock data not found for: " if os.path.exists(fileLocation): with open(fileLocation, 'rb') as block: retData = block.read() else: retData = _dbFetch(bHash) if retData is None: - raise onionrexceptions.NoDataAvailable("Block data for %s is not available" % [bHash]) - return retData \ No newline at end of file + raise onionrexceptions.NoDataAvailable(not_found_msg + str(bHash)) + return retData diff --git a/onionr/onionrstorage/removeblock.py b/src/onionrstorage/removeblock.py similarity index 100% rename from onionr/onionrstorage/removeblock.py rename to src/onionrstorage/removeblock.py diff --git a/onionr/onionrstorage/setdata.py b/src/onionrstorage/setdata.py similarity index 100% rename from onionr/onionrstorage/setdata.py rename to src/onionrstorage/setdata.py diff --git a/onionr/onionrtypes/__init__.py b/src/onionrtypes/__init__.py similarity index 77% rename from onionr/onionrtypes/__init__.py rename to src/onionrtypes/__init__.py index 88955237..74585249 100644 --- a/onionr/onionrtypes/__init__.py +++ b/src/onionrtypes/__init__.py @@ -6,5 +6,3 @@ UserIDSecretKey = NewType('UserIDSecretKey', str) DeterministicKeyPassphrase = NewType('DeterministicKeyPassphrase', str) BlockHash = NewType('BlockHash', str) - -RestartRequiredStatus = NewType('RestartRequiredStatus', bool) diff --git a/onionr/onionrusers/README.md b/src/onionrusers/README.md similarity index 100% rename from onionr/onionrusers/README.md rename to src/onionrusers/README.md diff --git a/onionr/onionrusers/__init__.py b/src/onionrusers/__init__.py similarity index 100% rename from onionr/onionrusers/__init__.py rename to src/onionrusers/__init__.py diff --git a/onionr/onionrusers/contactmanager.py b/src/onionrusers/contactmanager.py similarity index 100% rename from onionr/onionrusers/contactmanager.py rename to src/onionrusers/contactmanager.py diff --git a/onionr/onionrusers/onionrusers.py b/src/onionrusers/onionrusers.py similarity index 100% rename from onionr/onionrusers/onionrusers.py rename to src/onionrusers/onionrusers.py diff --git a/onionr/onionrutils/__init__.py b/src/onionrutils/__init__.py similarity index 100% rename from onionr/onionrutils/__init__.py rename to src/onionrutils/__init__.py diff --git a/onionr/onionrutils/basicrequests.py b/src/onionrutils/basicrequests.py similarity index 100% rename from onionr/onionrutils/basicrequests.py rename to src/onionrutils/basicrequests.py diff --git a/onionr/onionrutils/blockmetadata/__init__.py b/src/onionrutils/blockmetadata/__init__.py similarity index 100% rename from onionr/onionrutils/blockmetadata/__init__.py rename to src/onionrutils/blockmetadata/__init__.py diff --git a/onionr/onionrutils/blockmetadata/fromdata.py b/src/onionrutils/blockmetadata/fromdata.py similarity index 100% rename from onionr/onionrutils/blockmetadata/fromdata.py rename to src/onionrutils/blockmetadata/fromdata.py diff --git a/onionr/onionrutils/blockmetadata/hasblock.py b/src/onionrutils/blockmetadata/hasblock.py similarity index 100% rename from onionr/onionrutils/blockmetadata/hasblock.py rename to src/onionrutils/blockmetadata/hasblock.py diff --git a/onionr/onionrutils/blockmetadata/process.py b/src/onionrutils/blockmetadata/process.py similarity index 100% rename from onionr/onionrutils/blockmetadata/process.py rename to src/onionrutils/blockmetadata/process.py diff --git a/onionr/onionrutils/bytesconverter.py b/src/onionrutils/bytesconverter.py similarity index 100% rename from onionr/onionrutils/bytesconverter.py rename to src/onionrutils/bytesconverter.py diff --git a/onionr/onionrutils/checkcommunicator.py b/src/onionrutils/checkcommunicator.py similarity index 100% rename from onionr/onionrutils/checkcommunicator.py rename to src/onionrutils/checkcommunicator.py diff --git a/onionr/onionrutils/epoch.py b/src/onionrutils/epoch.py similarity index 100% rename from onionr/onionrutils/epoch.py rename to src/onionrutils/epoch.py diff --git a/onionr/onionrutils/escapeansi.py b/src/onionrutils/escapeansi.py similarity index 100% rename from onionr/onionrutils/escapeansi.py rename to src/onionrutils/escapeansi.py diff --git a/onionr/onionrutils/getclientapiserver.py b/src/onionrutils/getclientapiserver.py similarity index 100% rename from onionr/onionrutils/getclientapiserver.py rename to src/onionrutils/getclientapiserver.py diff --git a/onionr/onionrutils/importnewblocks.py b/src/onionrutils/importnewblocks.py similarity index 86% rename from onionr/onionrutils/importnewblocks.py rename to src/onionrutils/importnewblocks.py index 89aee4d6..4ba614fb 100644 --- a/onionr/onionrutils/importnewblocks.py +++ b/src/onionrutils/importnewblocks.py @@ -21,7 +21,6 @@ import glob import logger from onionrutils import blockmetadata from coredb import blockmetadb -from onionrblocks import blockimporter import filepaths import onionrcrypto as crypto def import_new_blocks(scanDir=''): @@ -41,10 +40,9 @@ def import_new_blocks(scanDir=''): with open(block, 'rb') as newBlock: block = block.replace(scanDir, '').replace('.dat', '') if crypto.hashers.sha3_hash(newBlock.read()) == block.replace('.dat', ''): - if blockimporter.importBlockFromData(newBlock.read()): - logger.info('Imported block %s.' % block, terminal=True) - else: - logger.warn('Unable to import block %s.' % block, terminal=True) + blockmetadb.add_to_block_DB(block.replace('.dat', ''), dataSaved=True) + logger.info('Imported block %s.' % block, terminal=True) + blockmetadata.process_block_metadata(block) else: logger.warn('Failed to verify hash for %s' % block, terminal=True) if not exist: diff --git a/onionr/onionrutils/localcommand.py b/src/onionrutils/localcommand.py similarity index 100% rename from onionr/onionrutils/localcommand.py rename to src/onionrutils/localcommand.py diff --git a/onionr/onionrutils/mnemonickeys.py b/src/onionrutils/mnemonickeys.py similarity index 100% rename from onionr/onionrutils/mnemonickeys.py rename to src/onionrutils/mnemonickeys.py diff --git a/onionr/onionrutils/stringvalidators.py b/src/onionrutils/stringvalidators.py similarity index 100% rename from onionr/onionrutils/stringvalidators.py rename to src/onionrutils/stringvalidators.py diff --git a/src/onionrutils/updater/__init__.py b/src/onionrutils/updater/__init__.py new file mode 100644 index 00000000..a9bdf13f --- /dev/null +++ b/src/onionrutils/updater/__init__.py @@ -0,0 +1,7 @@ +import notifier + + +def update_event(bl): + """Show update notification if available, return bool of if update happened""" + if not bl.isSigner(onionrvalues.UPDATE_SIGN_KEY): raise onionrexceptions.InvalidUpdate + onionr.notifier.notify(message="A new Onionr update is available. Stay updated to remain secure.") diff --git a/onionr/onionrutils/validatemetadata.py b/src/onionrutils/validatemetadata.py similarity index 97% rename from onionr/onionrutils/validatemetadata.py rename to src/onionrutils/validatemetadata.py index 916b3416..de22c5ae 100644 --- a/onionr/onionrutils/validatemetadata.py +++ b/src/onionrutils/validatemetadata.py @@ -1,9 +1,9 @@ -''' +""" Onionr - Private P2P Communication validate new block's metadata -''' -''' +""" +""" 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 @@ -16,14 +16,15 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . -''' +""" import json import logger, onionrexceptions from etc import onionrvalues -from onionrutils import stringvalidators, epoch, bytesconverter +from . import stringvalidators, epoch, bytesconverter import config, filepaths, onionrcrypto + def validate_metadata(metadata, block_data) -> bool: - '''Validate metadata meets onionr spec (does not validate proof value computation), take in either dictionary or json string''' + """Validate metadata meets onionr spec (does not validate proof value computation), take in either dictionary or json string""" ret_data = False max_clock_difference = onionrvalues.MAX_BLOCK_CLOCK_SKEW diff --git a/onionr/runtests/__init__.py b/src/runtests/__init__.py similarity index 100% rename from onionr/runtests/__init__.py rename to src/runtests/__init__.py diff --git a/onionr/runtests/inserttest.py b/src/runtests/inserttest.py similarity index 100% rename from onionr/runtests/inserttest.py rename to src/runtests/inserttest.py diff --git a/onionr/runtests/stresstest.py b/src/runtests/stresstest.py similarity index 100% rename from onionr/runtests/stresstest.py rename to src/runtests/stresstest.py diff --git a/onionr/runtests/uicheck.py b/src/runtests/uicheck.py similarity index 100% rename from onionr/runtests/uicheck.py rename to src/runtests/uicheck.py diff --git a/onionr/serializeddata.py b/src/serializeddata.py similarity index 89% rename from onionr/serializeddata.py rename to src/serializeddata.py index a44ca9df..35e14fc3 100755 --- a/onionr/serializeddata.py +++ b/src/serializeddata.py @@ -1,9 +1,9 @@ -''' +""" Onionr - Private P2P Communication This module serializes various data pieces for use in other modules, in particular the web api -''' -''' +""" +""" 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 @@ -16,24 +16,27 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . -''' +""" + +import json # noqa +import time # noqa + +from coredb import blockmetadb # noqa +import communicator # noqa -import json, time -from coredb import blockmetadb -import communicator class SerializedData: def __init__(self): - ''' + """ Serialized data is in JSON format: { 'success': bool, 'foo': 'bar', etc } - ''' + """ def get_stats(self): - '''Return statistics about our node''' + """Return statistics about our node""" stats = {} try: self._too_many diff --git a/onionr/utils/__init__.py b/src/utils/__init__.py similarity index 100% rename from onionr/utils/__init__.py rename to src/utils/__init__.py diff --git a/onionr/utils/cachedconfig/__init__.py b/src/utils/cachedconfig/__init__.py similarity index 100% rename from onionr/utils/cachedconfig/__init__.py rename to src/utils/cachedconfig/__init__.py diff --git a/onionr/utils/createdirs.py b/src/utils/createdirs.py similarity index 92% rename from onionr/utils/createdirs.py rename to src/utils/createdirs.py index 1c16767e..fb61e88c 100644 --- a/onionr/utils/createdirs.py +++ b/src/utils/createdirs.py @@ -29,10 +29,7 @@ def create_dirs(): gen_dirs = [home, filepaths.block_data_location, filepaths.contacts_location, filepaths.export_location] for path in gen_dirs: if not os.path.exists(path): - try: - os.mkdir(path) - except FileExistsError: - pass + os.mkdir(path) for db in dbcreator.create_funcs: try: diff --git a/onionr/utils/definewait.py b/src/utils/definewait.py similarity index 100% rename from onionr/utils/definewait.py rename to src/utils/definewait.py diff --git a/onionr/utils/getconsolewidth.py b/src/utils/getconsolewidth.py similarity index 100% rename from onionr/utils/getconsolewidth.py rename to src/utils/getconsolewidth.py diff --git a/onionr/utils/gethostname.py b/src/utils/gethostname.py similarity index 95% rename from onionr/utils/gethostname.py rename to src/utils/gethostname.py index 4a294218..42652fa1 100644 --- a/onionr/utils/gethostname.py +++ b/src/utils/gethostname.py @@ -21,6 +21,7 @@ from . import identifyhome import filepaths def get_hostname(): try: + print(identifyhome.identify_home()) with open(identifyhome.identify_home() + '/hs/hostname', 'r') as hostname: return hostname.read().strip() except FileNotFoundError: diff --git a/onionr/utils/gettransports.py b/src/utils/gettransports.py similarity index 100% rename from onionr/utils/gettransports.py rename to src/utils/gettransports.py diff --git a/onionr/utils/hastor.py b/src/utils/hastor.py similarity index 100% rename from onionr/utils/hastor.py rename to src/utils/hastor.py diff --git a/onionr/utils/identifyhome.py b/src/utils/identifyhome.py similarity index 100% rename from onionr/utils/identifyhome.py rename to src/utils/identifyhome.py diff --git a/onionr/utils/logoheader.py b/src/utils/logoheader.py similarity index 100% rename from onionr/utils/logoheader.py rename to src/utils/logoheader.py diff --git a/onionr/utils/netutils.py b/src/utils/netutils.py similarity index 100% rename from onionr/utils/netutils.py rename to src/utils/netutils.py diff --git a/onionr/utils/networkmerger.py b/src/utils/networkmerger.py similarity index 100% rename from onionr/utils/networkmerger.py rename to src/utils/networkmerger.py diff --git a/onionr/utils/readstatic.py b/src/utils/readstatic.py similarity index 100% rename from onionr/utils/readstatic.py rename to src/utils/readstatic.py diff --git a/onionr/utils/reconstructhash.py b/src/utils/reconstructhash.py similarity index 100% rename from onionr/utils/reconstructhash.py rename to src/utils/reconstructhash.py diff --git a/onionr/utils/safezip.py b/src/utils/safezip.py similarity index 100% rename from onionr/utils/safezip.py rename to src/utils/safezip.py diff --git a/onionr/utils/sizeutils.py b/src/utils/sizeutils.py similarity index 100% rename from onionr/utils/sizeutils.py rename to src/utils/sizeutils.py diff --git a/onionr/vanityonionr/__init__.py b/src/vanityonionr/__init__.py similarity index 100% rename from onionr/vanityonionr/__init__.py rename to src/vanityonionr/__init__.py diff --git a/static-data/www/mail/mail.js b/static-data/www/mail/mail.js index d65d933d..6f435ad2 100755 --- a/static-data/www/mail/mail.js +++ b/static-data/www/mail/mail.js @@ -91,8 +91,8 @@ function openThread(bHash, sender, date, sigBool, pubkey, subjectLine){ var sigEl = document.getElementById('sigValid') var sigMsg = 'signature' - // show add unknown contact button if peer is unknown but still has pubkey - if (sender === pubkey && sender !== myPub && sigBool){ + // show add unknown contact button if peer is unknown + if (sender !== myPub && sigBool){ addUnknownContact.style.display = 'inline' }