remove streamfill

This commit is contained in:
Kevin Froman 2021-02-02 06:57:37 +00:00
parent c40effd520
commit 582ac1607e
6 changed files with 0 additions and 125 deletions

View File

@ -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))

View File

@ -1,2 +0,0 @@
from .extracted25519 import extract_ed25519_from_onion_address
from .neighbors import identify_neighbors

View File

@ -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

View File

@ -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

View File

@ -1,10 +0,0 @@
from typing import List
from onionrutils.localcommand import local_command
from .neighbors import identify_neighbors
def stream_pool():
peers = lioc

View File

@ -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)