Compare commits
No commits in common. "b59e79a21fe93c1f0918f9bfdbbc160e17a889c1" and "264eeaa988cd50fe6d2d63ad051998477de753fc" have entirely different histories.
b59e79a21f
...
264eeaa988
|
@ -0,0 +1 @@
|
||||||
|
simplenotifications==0.2.18
|
|
@ -0,0 +1,8 @@
|
||||||
|
#
|
||||||
|
# This file is autogenerated by pip-compile
|
||||||
|
# To update, run:
|
||||||
|
#
|
||||||
|
# pip-compile --generate-hashes --output-file=requirements-notifications.txt requirements-notifications.in
|
||||||
|
#
|
||||||
|
simplenotifications==0.2.18 \
|
||||||
|
--hash=sha256:b7efd3d834b1922a3279287913d87fe4ef6fad181ca7edf54bfb8f1d973941e0
|
|
@ -77,7 +77,6 @@ def daemon():
|
||||||
logger.info(
|
logger.info(
|
||||||
f"Onionr daemon is running under pid {os.getpid()}", terminal=True)
|
f"Onionr daemon is running under pid {os.getpid()}", terminal=True)
|
||||||
events.event('init', threaded=False)
|
events.event('init', threaded=False)
|
||||||
events.event('afterinit', threaded=False)
|
|
||||||
events.event('daemon_start')
|
events.event('daemon_start')
|
||||||
|
|
||||||
add_onionr_thread(
|
add_onionr_thread(
|
||||||
|
|
|
@ -21,7 +21,6 @@ import os, re, importlib
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
from . import onionrevents as events
|
from . import onionrevents as events
|
||||||
from .pluginapis import plugin_apis
|
|
||||||
import config, logger
|
import config, logger
|
||||||
from utils import identifyhome
|
from utils import identifyhome
|
||||||
|
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
#
|
|
||||||
from typing import Callable, Dict
|
|
||||||
|
|
||||||
# plugin apis are methods intended to be available to the rpc
|
|
||||||
# plugin, this is so plugins can provide apis to other plugins
|
|
||||||
# plugins add their methods during or before afterinit event
|
|
||||||
plugin_apis: Dict[str, Callable] = {}
|
|
|
@ -28,12 +28,11 @@ def identify_home() -> str:
|
||||||
"""
|
"""
|
||||||
path = os.environ.get('ONIONR_HOME', None)
|
path = os.environ.get('ONIONR_HOME', None)
|
||||||
|
|
||||||
|
|
||||||
if path is None:
|
if path is None:
|
||||||
system = platform.system()
|
system = platform.system()
|
||||||
if system == 'Linux':
|
if system == 'Linux':
|
||||||
path = os.environ.get(
|
path = os.path.expanduser('~') + '/.local/share/onionr/'
|
||||||
'XDG_DATA_HOME',
|
|
||||||
os.path.expanduser('~') + '/.local/share/onionr/')
|
|
||||||
elif system == 'Darwin':
|
elif system == 'Darwin':
|
||||||
path = os.path.expanduser('~' +
|
path = os.path.expanduser('~' +
|
||||||
'/Library/Application Support/onionr/')
|
'/Library/Application Support/onionr/')
|
||||||
|
|
|
@ -6,7 +6,6 @@ import sys
|
||||||
import os
|
import os
|
||||||
import locale
|
import locale
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
from time import sleep
|
|
||||||
|
|
||||||
import cherrypy
|
import cherrypy
|
||||||
|
|
||||||
|
@ -38,13 +37,11 @@ PLUGIN_VERSION = '0.0.0'
|
||||||
socket_file_path = identifyhome.identify_home() + 'rpc.sock'
|
socket_file_path = identifyhome.identify_home() + 'rpc.sock'
|
||||||
|
|
||||||
from jsonrpc import JSONRPCResponseManager, dispatcher
|
from jsonrpc import JSONRPCResponseManager, dispatcher
|
||||||
import jsonrpc
|
|
||||||
import ujson
|
|
||||||
jsonrpc.manager.json = ujson
|
|
||||||
|
|
||||||
# RPC modules map Onionr APIs to the RPC dispacher
|
|
||||||
from rpc import blocks, pluginrpcmethods
|
|
||||||
|
|
||||||
|
@dispatcher.add_method
|
||||||
|
def foobar(**kwargs):
|
||||||
|
return kwargs["foo"] + kwargs["bar"]
|
||||||
|
|
||||||
class OnionrRPC(object):
|
class OnionrRPC(object):
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
|
@ -53,18 +50,16 @@ class OnionrRPC(object):
|
||||||
# Dispatcher is dictionary {<method_name>: callable}
|
# Dispatcher is dictionary {<method_name>: callable}
|
||||||
data = cherrypy.request.body.read().decode('utf-8')
|
data = cherrypy.request.body.read().decode('utf-8')
|
||||||
|
|
||||||
|
dispatcher["echo"] = lambda s: s
|
||||||
|
dispatcher["add"] = lambda a, b: a + b
|
||||||
|
|
||||||
response = JSONRPCResponseManager.handle(data, dispatcher)
|
response = JSONRPCResponseManager.handle(data, dispatcher)
|
||||||
return response.json
|
return response.json
|
||||||
|
|
||||||
|
|
||||||
def on_afterinit(api, data=None):
|
|
||||||
pluginrpcmethods.add_plugin_rpc_methods()
|
|
||||||
|
|
||||||
|
|
||||||
def on_init(api, data=None):
|
def on_init(api, data=None):
|
||||||
config = {
|
config = {
|
||||||
#'server.socket_file': socket_file_path,
|
'server.socket_file': socket_file_path,
|
||||||
'server.socket_port': 0,
|
|
||||||
'engine.autoreload.on': False
|
'engine.autoreload.on': False
|
||||||
}
|
}
|
||||||
cherrypy.config.update(config)
|
cherrypy.config.update(config)
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
from secrets import randbits
|
|
||||||
|
|
||||||
from onionrblocks import Block
|
|
||||||
from jsonrpc import dispatcher
|
|
||||||
import ujson
|
|
||||||
from base64 import b85decode
|
|
||||||
|
|
||||||
from gossip.blockqueues import gossip_block_queues
|
|
||||||
from blockdb import get_blocks_after_timestamp
|
|
||||||
|
|
||||||
|
|
||||||
@dispatcher.add_method
|
|
||||||
def get_blocks(timestamp):
|
|
||||||
return [block.raw for block in get_blocks_after_timestamp(timestamp)]
|
|
||||||
|
|
||||||
|
|
||||||
queue_to_use = randbits(1)
|
|
||||||
@dispatcher.add_method
|
|
||||||
def insert_block(block):
|
|
||||||
block = Block(
|
|
||||||
block['id'], b85decode(block['raw']), auto_verify=False)
|
|
||||||
gossip_block_queues[queue_to_use].put_nowait(block)
|
|
||||||
return "ok"
|
|
||||||
|
|
||||||
#dispatcher['get_blocks_after_timestamp'] = get_blocks_after_timestamp
|
|
|
@ -1,8 +0,0 @@
|
||||||
from jsonrpc import dispatcher
|
|
||||||
|
|
||||||
from onionrplugins.pluginapis import plugin_apis
|
|
||||||
|
|
||||||
|
|
||||||
def add_plugin_rpc_methods():
|
|
||||||
for method in plugin_apis:
|
|
||||||
dispatcher[method] = plugin_apis[method]
|
|
|
@ -1 +0,0 @@
|
||||||
PYTHONPATH=./venv/bin/python310:../../src/:./
|
|
|
@ -1,4 +0,0 @@
|
||||||
{ "name": "example",
|
|
||||||
"version": "0.0.0",
|
|
||||||
"author": "onionr"
|
|
||||||
}
|
|
|
@ -1,52 +0,0 @@
|
||||||
"""Onionr - Private P2P Communication.
|
|
||||||
|
|
||||||
Default example plugin for devs or to test blocks
|
|
||||||
"""
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
import locale
|
|
||||||
from time import sleep
|
|
||||||
import traceback
|
|
||||||
from typing import Set, TYPE_CHECKING
|
|
||||||
from threading import Thread, local
|
|
||||||
import blockdb
|
|
||||||
from gossip.peerset import gossip_peer_set
|
|
||||||
|
|
||||||
|
|
||||||
import logger
|
|
||||||
|
|
||||||
import onionrplugins
|
|
||||||
|
|
||||||
locale.setlocale(locale.LC_ALL, '')
|
|
||||||
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)))
|
|
||||||
# import after path insert
|
|
||||||
|
|
||||||
"""
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
plugin_name = 'wot'
|
|
||||||
PLUGIN_VERSION = '0.0.0'
|
|
||||||
|
|
||||||
|
|
||||||
def wot_test(arg: int):
|
|
||||||
return arg + 1
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def on_init(api, data=None):
|
|
||||||
logger.info(
|
|
||||||
f"Web of Trust Plugin v{PLUGIN_VERSION} enabled", terminal=True)
|
|
||||||
onionrplugins.plugin_apis['wot'] = wot_test
|
|
Loading…
Reference in New Issue