From 582ac1607e30585be8bcd702940fbbceffaa0bcc Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Tue, 2 Feb 2021 06:57:37 +0000 Subject: [PATCH] remove streamfill --- scripts/closeness-calculator.py | 21 ---------------- src/streamfill/__init__.py | 2 -- src/streamfill/extracted25519.py | 14 ----------- src/streamfill/neighbors.py | 40 ------------------------------- src/streamfill/pool.py | 10 -------- src/streamfill/tunnel/__init__.py | 38 ----------------------------- 6 files changed, 125 deletions(-) delete mode 100644 scripts/closeness-calculator.py delete mode 100644 src/streamfill/__init__.py delete mode 100644 src/streamfill/extracted25519.py delete mode 100644 src/streamfill/neighbors.py delete mode 100644 src/streamfill/pool.py delete mode 100644 src/streamfill/tunnel/__init__.py diff --git a/scripts/closeness-calculator.py b/scripts/closeness-calculator.py deleted file mode 100644 index cd162fbd..00000000 --- a/scripts/closeness-calculator.py +++ /dev/null @@ -1,21 +0,0 @@ -import sys -import os -import subprocess -import base64 -if not os.path.exists('onionr.sh'): - os.chdir('../') -sys.path.append("src/") -from streamfill import identify_neighbors - -onions = [] -p = subprocess.Popen(["scripts/generate-onions.py", '5'], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) -for line in iter(p.stdout.readline, b''): - line = line.decode() - onions.append(line.strip()) - - -for onion in onions: - print(onion, identify_neighbors(onion, onions, 3)) - diff --git a/src/streamfill/__init__.py b/src/streamfill/__init__.py deleted file mode 100644 index 1142cf4b..00000000 --- a/src/streamfill/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -from .extracted25519 import extract_ed25519_from_onion_address -from .neighbors import identify_neighbors \ No newline at end of file diff --git a/src/streamfill/extracted25519.py b/src/streamfill/extracted25519.py deleted file mode 100644 index 8b9ab5c7..00000000 --- a/src/streamfill/extracted25519.py +++ /dev/null @@ -1,14 +0,0 @@ -from base64 import b32decode -from typing import TYPE_CHECKING - -from onionrutils.bytesconverter import str_to_bytes - -if TYPE_CHECKING: - from onionrtypes import Ed25519PublicKeyBytes, OnionAddressString - - -def extract_ed25519_from_onion_address( - address: 'OnionAddressString') -> 'Ed25519PublicKeyBytes': - address = str_to_bytes(address).replace(b'.onion', b'').upper() - ed25519 = b32decode(address)[:-3] - return ed25519 \ No newline at end of file diff --git a/src/streamfill/neighbors.py b/src/streamfill/neighbors.py deleted file mode 100644 index 10263872..00000000 --- a/src/streamfill/neighbors.py +++ /dev/null @@ -1,40 +0,0 @@ -from onionrtypes import OnionAddressString -from typing import Iterable - -from collections import OrderedDict - -from .extracted25519 import extract_ed25519_from_onion_address - - -def identify_neighbors( - address: OnionAddressString, - peers: Iterable[OnionAddressString], - closest_n: int) -> OnionAddressString: - """Identify node addresses that are closest - in value to a given node address""" - peers_to_test = list(peers) - - try: - peers_to_test.remove(address) - except ValueError: - pass - - address = extract_ed25519_from_onion_address(address) - address_int = int.from_bytes(address, "big") - closeness_values = [] - end_result = [] - - def _calc_closeness(y): - ret = abs( - address_int - - int.from_bytes(extract_ed25519_from_onion_address(y), "big")) - return ret - - for peer in peers_to_test: - closeness_values.append((peer, _calc_closeness(peer))) - closeness_values.sort(key=lambda p: p[1]) - for i, result in enumerate(closeness_values): - end_result.append(result[0]) - if i > closest_n: - break - return end_result diff --git a/src/streamfill/pool.py b/src/streamfill/pool.py deleted file mode 100644 index 02e56921..00000000 --- a/src/streamfill/pool.py +++ /dev/null @@ -1,10 +0,0 @@ -from typing import List - -from onionrutils.localcommand import local_command -from .neighbors import identify_neighbors - - -def stream_pool(): - - peers = lioc - diff --git a/src/streamfill/tunnel/__init__.py b/src/streamfill/tunnel/__init__.py deleted file mode 100644 index 762976e2..00000000 --- a/src/streamfill/tunnel/__init__.py +++ /dev/null @@ -1,38 +0,0 @@ -from secrets import token_bytes -from typing import TYPE_CHECKING -import socket - -if TYPE_CHECKING: - from stem.control import Controller - -from onionrtypes import OnionAddressString - -import yam - - -def peer_tunnel(tor_controller: Controller, peer): - socks_port = tor_controller.get_conf('SocksPort') - - class Connected: - connected = False - - send_buffer = [] - rec_buffer = [] - rec_address = None - - yam.client(1, peer, socks_port, send_buffer, rec_buffer, Connected) - with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: - ip = '127.0.0.1' - s.bind((ip, 0)) - s.listen(1) - port = s.getsockname()[1] - serv = tor_controller.create_ephemeral_hidden_service( - {1337: '127.0.0.1:' + str(port)}, - key_content='ED25519-V3', - await_publication=True, - ) - rec_address = serv.service_id - conn, addr = s.accept() - yam.server(1, tor_controller, conn, send_buffer, rec_buffer, Connected) - -