')
+
+# event listeners
+
+def on_init(api, data = None):
+ global pluginapi
+ pluginapi = api
+ check()
+
+ # register some commands
+ api.commands.register(['install-plugin', 'installplugin', 'plugin-install', 'install', 'plugininstall'], commandInstallPlugin)
+ api.commands.register(['remove-plugin', 'removeplugin', 'plugin-remove', 'uninstall-plugin', 'uninstallplugin', 'plugin-uninstall', 'uninstall', 'remove', 'pluginremove'], commandUninstallPlugin)
+ api.commands.register(['search', 'filter-plugins', 'search-plugins', 'searchplugins', 'search-plugin', 'searchplugin', 'findplugin', 'find-plugin', 'filterplugin', 'plugin-search', 'pluginsearch'], commandSearchPlugin)
+ api.commands.register(['add-repo', 'add-repository', 'addrepo', 'addrepository', 'repository-add', 'repo-add', 'repoadd', 'addrepository', 'add-plugin-repository', 'add-plugin-repo', 'add-pluginrepo', 'add-pluginrepository', 'addpluginrepo', 'addpluginrepository'], commandAddRepository)
+ api.commands.register(['remove-repo', 'remove-repository', 'removerepo', 'removerepository', 'repository-remove', 'repo-remove', 'reporemove', 'removerepository', 'remove-plugin-repository', 'remove-plugin-repo', 'remove-pluginrepo', 'remove-pluginrepository', 'removepluginrepo', 'removepluginrepository', 'rm-repo', 'rm-repository', 'rmrepo', 'rmrepository', 'repository-rm', 'repo-rm', 'reporm', 'rmrepository', 'rm-plugin-repository', 'rm-plugin-repo', 'rm-pluginrepo', 'rm-pluginrepository', 'rmpluginrepo', 'rmpluginrepository'], commandRemoveRepository)
+ api.commands.register(['publish-plugin', 'plugin-publish', 'publishplugin', 'pluginpublish', 'publish'], commandPublishPlugin)
+
+ # add help menus once the features are actually implemented
+
+ return
diff --git a/onionr/static-data/default_config.json b/onionr/static-data/default_config.json
new file mode 100644
index 00000000..ccafd7a4
--- /dev/null
+++ b/onionr/static-data/default_config.json
@@ -0,0 +1,20 @@
+{
+ "devmode": true,
+ "dc_response": true,
+
+ "log": {
+ "file": {
+ "output": true,
+ "path": "data/output.log"
+ },
+
+ "console": {
+ "output": true,
+ "color": true
+ }
+ },
+ "allocations":{
+ "disk": 1000000000,
+ "netTotal": 1000000000
+ }
+}
diff --git a/onionr/static-data/default_plugin.py b/onionr/static-data/default_plugin.py
new file mode 100644
index 00000000..cc6d1d20
--- /dev/null
+++ b/onionr/static-data/default_plugin.py
@@ -0,0 +1,43 @@
+'''
+ $name plugin template file.
+ Generated on $date by $user.
+'''
+
+# Imports some useful libraries
+import logger, config
+
+plugin_name = '$name'
+
+def on_init(api, data = None):
+ '''
+ This event is called after Onionr is initialized, but before the command
+ inputted is executed. Could be called when daemon is starting or when
+ just the client is running.
+ '''
+
+ # Doing this makes it so that the other functions can access the api object
+ # by simply referencing the variable `pluginapi`.
+ global pluginapi
+ pluginapi = api
+
+ return
+
+def on_start(api, data = None):
+ '''
+ This event can be called for multiple reasons:
+ 1) The daemon is starting
+ 2) The user called `onionr --start-plugins` or `onionr --reload-plugins`
+ 3) For whatever reason, the plugins are reloading
+ '''
+
+ return
+
+def on_stop(api, data = None):
+ '''
+ This event can be called for multiple reasons:
+ 1) The daemon is stopping
+ 2) The user called `onionr --stop-plugins` or `onionr --reload-plugins`
+ 3) For whatever reason, the plugins are reloading
+ '''
+
+ return
diff --git a/onionr/static-data/index.html b/onionr/static-data/index.html
new file mode 100644
index 00000000..6cd0c558
--- /dev/null
+++ b/onionr/static-data/index.html
@@ -0,0 +1,5 @@
+This is an Onionr Node
+
+The content on this server is not necessarily created or intentionally stored by the owner of the software.
+
+To learn more about Onionr, see the website at https://Onionr.VoidNet.tech/
diff --git a/onionr/tests.py b/onionr/tests.py
index 18e6187d..db62dcb3 100755
--- a/onionr/tests.py
+++ b/onionr/tests.py
@@ -14,7 +14,7 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see .
'''
-import unittest, sys, os, base64, tarfile, shutil, simplecrypt, logger, btc
+import unittest, sys, os, base64, tarfile, shutil, simplecrypt, logger #, btc
class OnionrTests(unittest.TestCase):
def testPython3(self):
@@ -56,7 +56,7 @@ class OnionrTests(unittest.TestCase):
myCore = core.Core()
if not os.path.exists('data/peers.db'):
myCore.createPeerDB()
- if myCore.addPeer('6M5MXL237OK57ITHVYN5WGHANPGOMKS5C3PJLHBBNKFFJQOIDOJA====') and not myCore.addPeer('NFXHMYLMNFSAU==='):
+ if myCore.addPeer('6M5MXL237OK57ITHVYN5WGHANPGOMKS5C3PJLHBBNKFFJQOIDOJA====', '1cSix9Ao/yQSdo0sNif8cm2uTcYnSphb4JdZL/3WkN4=') and not myCore.addPeer('NFXHMYLMNFSAU===', '1cSix9Ao/yQSdo0sNif8cm2uTcYnSphb4JdZL/3WkN4='):
self.assertTrue(True)
else:
self.assertTrue(False)
@@ -129,7 +129,14 @@ class OnionrTests(unittest.TestCase):
logger.debug('-'*26 + '\n')
logger.info('Running simple plugin reload test...')
- import onionrplugins
+ import onionrplugins, os
+
+ if not onionrplugins.exists('test'):
+ os.makedirs(onionrplugins.get_plugins_folder('test'))
+ with open(onionrplugins.get_plugins_folder('test') + '/main.py', 'a') as main:
+ main.write("print('Running')\n\ndef on_test(pluginapi, data = None):\n print('received test event!')\n return True\n\ndef on_start(pluginapi, data = None):\n print('start event called')\n\ndef on_stop(pluginapi, data = None):\n print('stop event called')\n\ndef on_enable(pluginapi, data = None):\n print('enable event called')\n\ndef on_disable(pluginapi, data = None):\n print('disable event called')\n")
+ onionrplugins.enable('test')
+
try:
onionrplugins.reload('test')
self.assertTrue(True)
@@ -140,7 +147,14 @@ class OnionrTests(unittest.TestCase):
logger.debug('-'*26 + '\n')
logger.info('Running simple plugin restart test...')
- import onionrplugins
+ import onionrplugins, os
+
+ if not onionrplugins.exists('test'):
+ os.makedirs(onionrplugins.get_plugins_folder('test'))
+ with open(onionrplugins.get_plugins_folder('test') + '/main.py', 'a') as main:
+ main.write("print('Running')\n\ndef on_test(pluginapi, data = None):\n print('received test event!')\n return True\n\ndef on_start(pluginapi, data = None):\n print('start event called')\n\ndef on_stop(pluginapi, data = None):\n print('stop event called')\n\ndef on_enable(pluginapi, data = None):\n print('enable event called')\n\ndef on_disable(pluginapi, data = None):\n print('disable event called')\n")
+ onionrplugins.enable('test')
+
try:
onionrplugins.start('test')
onionrplugins.stop('test')
@@ -152,13 +166,24 @@ class OnionrTests(unittest.TestCase):
logger.debug('-'*26 + '\n')
logger.info('Running plugin event test...')
- import onionrplugins as plugins, onionrevents as events
+ import onionrplugins as plugins, onionrevents as events, os
+
+ if not plugins.exists('test'):
+ os.makedirs(plugins.get_plugins_folder('test'))
+ with open(plugins.get_plugins_folder('test') + '/main.py', 'a') as main:
+ main.write("print('Running')\n\ndef on_test(pluginapi, data = None):\n print('received test event!')\n print('thread test started...')\n import time\n time.sleep(1)\n \n return True\n\ndef on_start(pluginapi, data = None):\n print('start event called')\n\ndef on_stop(pluginapi, data = None):\n print('stop event called')\n\ndef on_enable(pluginapi, data = None):\n print('enable event called')\n\ndef on_disable(pluginapi, data = None):\n print('disable event called')\n")
+ plugins.enable('test')
+
plugins.start('test')
- if not events.call(plugins.get_plugin('test'), 'test'):
+ if not events.call(plugins.get_plugin('test'), 'enable'):
self.assertTrue(False)
- events.event('test', data = {'tests': self})
+ logger.debug('preparing to start thread', timestamp = False)
+ thread = events.event('test', data = {'tests': self})
+ logger.debug('thread running...', timestamp = False)
+ thread.join()
+ logger.debug('thread finished.', timestamp = False)
self.assertTrue(True)
diff --git a/onionr/timedHmac.py b/onionr/timedhmac.py
similarity index 93%
rename from onionr/timedHmac.py
rename to onionr/timedhmac.py
index 2f23317f..a6163ead 100644
--- a/onionr/timedHmac.py
+++ b/onionr/timedhmac.py
@@ -12,7 +12,9 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see .
'''
+
import hmac, base64, time, math
+
class TimedHMAC:
def __init__(self, base64Key, data, hashAlgo):
'''
@@ -23,6 +25,7 @@ class TimedHMAC:
Maximum of 10 seconds grace period
'''
+
self.data = data
self.expire = math.floor(time.time())
self.hashAlgo = hashAlgo
@@ -34,11 +37,14 @@ class TimedHMAC:
return
def check(self, data):
- # Check a hash (and verify time is sane)
+ '''
+ Check a hash (and verify time is sane)
+ '''
+
testHash = hmac.HMAC(base64.b64decode(base64Key).decode(), digestmod=self.hashAlgo)
testHash.update(data + math.floor(time.time()))
testHash = testHash.hexdigest()
if hmac.compare_digest(testHash, self.HMACResult):
return true
- else:
- return false
+
+ return false
diff --git a/requirements.txt b/requirements.txt
index 4ad9ff99..ffdcdf77 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,8 +1,11 @@
-PyNaCl==1.2.1
-requests==2.12.4
-Flask==0.12.2
-simple_crypt==4.1.7
urllib3==1.19.1
+gevent==1.2.2
+PyNaCl==1.2.1
+pycoin==0.62
+Flask==1.0
sha3==0.2.1
-PySocks==1.6.8
-bitpeer.py==0.4.7.5
+simple_crypt==4.1.7
+ecdsa==0.13
+requests==2.12.4
+SocksiPy_branch==1.01
+sphinx_rtd_theme==0.3.0