From d9c0adcc7b35779fee23577affe34d325365a5d8 Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Mon, 8 Feb 2021 07:32:31 +0000 Subject: [PATCH] work on torgossip --- src/bigbrother/ministry/ofexec.py | 10 +++++----- static-data/default-plugins/torgossip/client.py | 6 +++++- .../default-plugins/torgossip/clientfuncs/__init__.py | 7 +++++++ static-data/default-plugins/torgossip/constants.py | 8 +++++--- .../default-plugins/torgossip/torgossip_config.json | 4 ++++ 5 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/bigbrother/ministry/ofexec.py b/src/bigbrother/ministry/ofexec.py index 37798a11..705d9072 100644 --- a/src/bigbrother/ministry/ofexec.py +++ b/src/bigbrother/ministry/ofexec.py @@ -76,11 +76,11 @@ def block_exec(event, info): code_b64 = base64.b64encode(info[0].co_code).decode() if code_b64 in whitelisted_source: return - # uncomment when you want to build on the whitelist - #else: - # with open("../static-data/base64-code-whitelist.txt", "a") as f: - # f.write(code_b64 + "\n") - # return + #uncomment when you want to build on the whitelist + else: + with open("../static-data/base64-code-whitelist.txt", "a") as f: + f.write(code_b64 + "\n") + return for source in whitelisted_code: if info[0].co_filename.endswith(source): diff --git a/static-data/default-plugins/torgossip/client.py b/static-data/default-plugins/torgossip/client.py index b55e5d8d..2570d794 100644 --- a/static-data/default-plugins/torgossip/client.py +++ b/static-data/default-plugins/torgossip/client.py @@ -77,10 +77,14 @@ def _client_pool(shared_state, socket_pool: dict): def client_loop(shared_state, socket_pool): + block_db = shared_state.get_by_string('SafeDB') + peer_db = shared_state.get_by_string('TorGossipPeers') + while True: if not socket_pool: _client_pool(shared_state, socket_pool) - + sync_ + diff --git a/static-data/default-plugins/torgossip/clientfuncs/__init__.py b/static-data/default-plugins/torgossip/clientfuncs/__init__.py index e69de29b..f6553056 100644 --- a/static-data/default-plugins/torgossip/clientfuncs/__init__.py +++ b/static-data/default-plugins/torgossip/clientfuncs/__init__.py @@ -0,0 +1,7 @@ +from typing import TYPE_CHECKING +if TYPE_CHECKING: + from socket import socket + + +def download_blocks(sock: 'socket', offset: int): + sock.sendall() diff --git a/static-data/default-plugins/torgossip/constants.py b/static-data/default-plugins/torgossip/constants.py index 7a9cad43..a2bb7ebc 100644 --- a/static-data/default-plugins/torgossip/constants.py +++ b/static-data/default-plugins/torgossip/constants.py @@ -1,4 +1,6 @@ from utils.identifyhome import identify_home -SERVER_SOCKET = identify_home() + "torgossip.sock" -HOSTNAME_FILE = identify_home() + "torgossip-hostname" -GOSSIP_PORT = 2020 \ No newline at end of file +home = identify_home() +SERVER_SOCKET = home + "torgossip.sock" +HOSTNAME_FILE = home + "torgossip-hostname" +CONFIG_FILE = home + "torgossip_config.json" +GOSSIP_PORT = 2021 diff --git a/static-data/default-plugins/torgossip/torgossip_config.json b/static-data/default-plugins/torgossip/torgossip_config.json index e69de29b..7a3d5be5 100644 --- a/static-data/default-plugins/torgossip/torgossip_config.json +++ b/static-data/default-plugins/torgossip/torgossip_config.json @@ -0,0 +1,4 @@ +{ + "fanout": 4, + "run_server": true +} \ No newline at end of file