mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-19 13:07:56 +00:00
Store the tub on the subclass, since we'll want it (or rather its Listeners) for
NURL construction.
This commit is contained in:
parent
03d9ff395c
commit
1798966f03
@ -819,9 +819,7 @@ class _Client(node.Node, pollmixin.PollMixin):
|
||||
furl_file = self.config.get_private_path("storage.furl").encode(get_filesystem_encoding())
|
||||
furl = self.tub.registerReference(FoolscapStorageServer(ss), furlFile=furl_file)
|
||||
(_, _, swissnum) = furl.rpartition("/")
|
||||
self.tub.negotiationClass.add_storage_server(
|
||||
self.tub.myCertificate, ss, swissnum.encode("ascii")
|
||||
)
|
||||
self.tub.negotiationClass.add_storage_server(ss, swissnum.encode("ascii"))
|
||||
|
||||
announcement["anonymous-storage-FURL"] = furl
|
||||
|
||||
|
@ -48,21 +48,25 @@ class _FoolscapOrHttps(Protocol, metaclass=_PretendToBeNegotiation):
|
||||
Do not use directly; this needs to be subclassed per ``Tub``.
|
||||
"""
|
||||
|
||||
# These three will be set by a subclass in update_foolscap_or_http_class()
|
||||
# below.
|
||||
# These will be set by support_foolscap_and_https() and add_storage_server().
|
||||
|
||||
# The swissnum for the storage_server.
|
||||
swissnum: bytes
|
||||
certificate: PrivateCertificate
|
||||
# The storage server we're exposing.
|
||||
storage_server: StorageServer
|
||||
# The tub that created us:
|
||||
tub: Tub
|
||||
# The certificate for the endpoint:
|
||||
certificate: PrivateCertificate
|
||||
|
||||
_timeout: IDelayedCall
|
||||
|
||||
@classmethod
|
||||
def add_storage_server(cls, certificate, storage_server, swissnum):
|
||||
def add_storage_server(cls, storage_server, swissnum):
|
||||
"""
|
||||
Add the various parameters needed by a ``Tub``-specific
|
||||
``_FoolscapOrHttps`` subclass.
|
||||
Add the various storage server-related attributes needed by a
|
||||
``Tub``-specific ``_FoolscapOrHttps`` subclass.
|
||||
"""
|
||||
cls.certificate = certificate
|
||||
cls.storage_server = storage_server
|
||||
cls.swissnum = swissnum
|
||||
|
||||
@ -141,8 +145,10 @@ def support_foolscap_and_https(tub: Tub):
|
||||
Create a new Foolscap-or-HTTPS protocol class for a specific ``Tub``
|
||||
instance.
|
||||
"""
|
||||
the_tub = tub
|
||||
|
||||
class FoolscapOrHttpWithCert(_FoolscapOrHttps):
|
||||
pass
|
||||
tub = the_tub
|
||||
certificate = tub.myCertificate
|
||||
|
||||
tub.negotiationClass = FoolscapOrHttpWithCert # type: ignore
|
||||
|
Loading…
Reference in New Issue
Block a user