From d388bba6461ae298ba86b9c283c7cca0a5246d6b Mon Sep 17 00:00:00 2001 From: Kevin F Date: Wed, 9 Feb 2022 19:29:16 -0600 Subject: [PATCH] Added files for new dandelion++ gossip and transport system --- src/gossip/__init__.py | 28 +++++++++++++++ src/gossip/client.py | 0 src/gossip/peer.py | 11 ++++++ src/gossip/server.py | 0 static-data/default-plugins/tor/info.json | 4 +++ static-data/default-plugins/tor/main.py | 44 +++++++++++++++++++++++ 6 files changed, 87 insertions(+) create mode 100644 src/gossip/__init__.py create mode 100644 src/gossip/client.py create mode 100644 src/gossip/peer.py create mode 100644 src/gossip/server.py create mode 100644 static-data/default-plugins/tor/info.json create mode 100644 static-data/default-plugins/tor/main.py diff --git a/src/gossip/__init__.py b/src/gossip/__init__.py new file mode 100644 index 00000000..e334b6a4 --- /dev/null +++ b/src/gossip/__init__.py @@ -0,0 +1,28 @@ +from typing import TYPE_CHECKING +if TYPE_CHECKING: + import queue + from onionrblocks import Block + +from onionrthreads import add_onionr_thread +""" +Onionr uses a flavor of Dandelion++ epidemic routing + +The starter creates a peer set and passes it to the client and server +as well as each of the plugins. + +The transports forward incoming requests to the gossip server + +When a new peer announcement is recieved an event is fired and the transport plugin that handles it will (or wont) +create a new peer object by connecting to that peer + +When a new block is generated, it is added to a queue in raw form passed to the starter + + +""" + +def start_gossip_threads(block_queue: queue.Queue[Block]): + # Peer set is largely handled by the transport plugins + # There is a unified set so gossip logic is not repeated + peer_set = set() + + diff --git a/src/gossip/client.py b/src/gossip/client.py new file mode 100644 index 00000000..e69de29b diff --git a/src/gossip/peer.py b/src/gossip/peer.py new file mode 100644 index 00000000..210bf41b --- /dev/null +++ b/src/gossip/peer.py @@ -0,0 +1,11 @@ +class Peer: + def __init__(self): + self.stats = {} + self.sock = None + self.id = "" + def send(self, data: bytes): + return + def disconnect(self): + return + + diff --git a/src/gossip/server.py b/src/gossip/server.py new file mode 100644 index 00000000..e69de29b diff --git a/static-data/default-plugins/tor/info.json b/static-data/default-plugins/tor/info.json new file mode 100644 index 00000000..6faee9ef --- /dev/null +++ b/static-data/default-plugins/tor/info.json @@ -0,0 +1,4 @@ +{ "name": "tor", + "version": "0.0.0", + "author": "onionr" + } \ No newline at end of file diff --git a/static-data/default-plugins/tor/main.py b/static-data/default-plugins/tor/main.py new file mode 100644 index 00000000..1a1506ae --- /dev/null +++ b/static-data/default-plugins/tor/main.py @@ -0,0 +1,44 @@ +"""Onionr - Private P2P Communication. + +This default plugin handles "flow" messages +(global chatroom style communication) +""" +import sys +import os +import locale + + +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 . +""" + +#flask_blueprint = flowapi.flask_blueprint +#security_whitelist = ['circles.circlesstatic', 'circles.circlesindex'] + +plugin_name = 'tor' +PLUGIN_VERSION = '0.0.0' + + +class OnionrTor: + def __init__(self): + return + + +def on_init(api, data=None): + print("plugin init") + return