mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-04-21 09:11:12 +00:00
Add a safety check.
This commit is contained in:
parent
2741fb2b46
commit
1ed440812a
@ -341,6 +341,9 @@ class StorageClient(object):
|
||||
cls,
|
||||
nurl: DecodedURL,
|
||||
reactor,
|
||||
# TODO default_connection_handlers should really be a class, not a dict
|
||||
# of strings...
|
||||
default_connection_handlers: dict[str, str],
|
||||
pool: Optional[HTTPConnectionPool] = None,
|
||||
agent_factory: Optional[
|
||||
Callable[[object, IPolicyForHTTPS, HTTPConnectionPool], IAgent]
|
||||
@ -349,6 +352,11 @@ class StorageClient(object):
|
||||
"""
|
||||
Create a ``StorageClient`` for the given NURL.
|
||||
"""
|
||||
# Safety check: if we're using normal TCP connections, we better not be
|
||||
# configured for Tor or I2P.
|
||||
if agent_factory is None:
|
||||
assert default_connection_handlers["tcp"] == "tcp"
|
||||
|
||||
assert nurl.fragment == "v=1"
|
||||
assert nurl.scheme == "pb"
|
||||
swissnum = nurl.path[0].encode("ascii")
|
||||
|
@ -1274,14 +1274,19 @@ class HTTPNativeStorageServer(service.MultiService):
|
||||
pool = HTTPConnectionPool(reactor, persistent=False)
|
||||
pool.retryAutomatically = False
|
||||
return StorageClientGeneral(
|
||||
StorageClient.from_nurl(nurl, reactor, pool, agent_factory=agent_factory)
|
||||
StorageClient.from_nurl(
|
||||
nurl, reactor, self._default_connection_handlers,
|
||||
pool=pool, agent_factory=agent_factory)
|
||||
).get_version()
|
||||
|
||||
nurl = await _pick_a_http_server(reactor, self._nurls, request)
|
||||
|
||||
# If we've gotten this far, we've found a working NURL.
|
||||
self._istorage_server = _HTTPStorageServer.from_http_client(
|
||||
StorageClient.from_nurl(nurl, reactor, agent_factory=agent_factory)
|
||||
StorageClient.from_nurl(
|
||||
nurl, reactor, self._default_connection_handlers,
|
||||
agent_factory=agent_factory
|
||||
)
|
||||
)
|
||||
return self._istorage_server
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user