Use getClientAddress instead of getClientIP. (#12599)

getClientIP was deprecated in Twisted 18.4.0, which also added
getClientAddress. The Synapse minimum version for Twisted is
currently 18.9.0, so all supported versions have the new API.
This commit is contained in:
Patrick Cloke 2022-05-04 14:11:21 -04:00 committed by GitHub
parent 116a4c8340
commit 7fbf42499d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 62 additions and 46 deletions

View file

@ -181,7 +181,7 @@ class FakeChannel:
self.resource_usage = _self.logcontext.get_resource_usage()
def getPeer(self):
# We give an address so that getClientIP returns a non null entry,
# We give an address so that getClientAddress/getClientIP returns a non null entry,
# causing us to record the MAU
return address.IPv4Address("TCP", self._ip, 3423)
@ -562,7 +562,10 @@ class FakeTransport:
"""
_peer_address: Optional[IAddress] = attr.ib(default=None)
"""The value to be returend by getPeer"""
"""The value to be returned by getPeer"""
_host_address: Optional[IAddress] = attr.ib(default=None)
"""The value to be returned by getHost"""
disconnecting = False
disconnected = False
@ -571,11 +574,11 @@ class FakeTransport:
producer = attr.ib(default=None)
autoflush = attr.ib(default=True)
def getPeer(self):
def getPeer(self) -> Optional[IAddress]:
return self._peer_address
def getHost(self):
return None
def getHost(self) -> Optional[IAddress]:
return self._host_address
def loseConnection(self, reason=None):
if not self.disconnecting: