network: use TOR stream isolation

also refactor, for proxy instantiation, use Network instance, not a proxy dict.
This commit is contained in:
Sander van Grieken
2024-10-14 13:32:22 +02:00
parent 0f26f38d18
commit f4520b9e0d
7 changed files with 35 additions and 23 deletions

View File

@@ -44,7 +44,7 @@ from aiorpcx.jsonrpc import JSONRPC, CodeMessageError
from aiorpcx.rawsocket import RSClient
import certifi
from .util import (ignore_exceptions, log_exceptions, bfh, MySocksProxy,
from .util import (ignore_exceptions, log_exceptions, bfh, ESocksProxy,
is_integer, is_non_negative_integer, is_hash256_str, is_hex_str,
is_int_or_float, is_non_negative_int_or_float, OldTaskGroup)
from . import util
@@ -375,7 +375,7 @@ class Interface(Logger):
LOGGING_SHORTCUT = 'i'
def __init__(self, *, network: 'Network', server: ServerAddr, proxy: Optional[dict]):
def __init__(self, *, network: 'Network', server: ServerAddr):
self.ready = network.asyncio_loop.create_future()
self.got_disconnected = asyncio.Event()
self.server = server
@@ -394,8 +394,9 @@ class Interface(Logger):
# addresses...? e.g. 192.168.x.x
if util.is_localhost(server.host):
self.logger.info(f"looks like localhost: not using proxy for this server")
proxy = None
self.proxy = MySocksProxy.from_proxy_dict(proxy)
self.proxy = None
else:
self.proxy = ESocksProxy.from_network_settings(network)
# Latest block header and corresponding height, as claimed by the server.
# Note that these values are updated before they are verified.