commit a21991541ef3ac9cf661711fe66b902e794e75b9 Author: meskio meskio@torproject.org Date: Wed Dec 1 20:32:16 2021 +0100
Skip bridges with invalid IP address
rdsys is providing bridges with non-public IP addresses, skip them. We need to fix that in rdsys side also. --- bridgedb/bridges.py | 4 +++- bridgedb/rdsys.py | 9 ++++++--- 2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/bridgedb/bridges.py b/bridgedb/bridges.py index 91fa7f6..de9eefe 100644 --- a/bridgedb/bridges.py +++ b/bridgedb/bridges.py @@ -1554,6 +1554,8 @@ class Bridge(BridgeBackwardsCompatibility): """ self.fingerprint = resource["fingerprint"] self.address = resource["address"] + if not self.address: + raise MalformedBridgeInfo("Invalid address for a bridge (%s): %s" % (resource["fingerprint"], resource["address"]))
self.flags.running = resource["flags"]["running"] self.flags.stable = resource["flags"]["stable"] @@ -1572,7 +1574,7 @@ class Bridge(BridgeBackwardsCompatibility): transport = PluggableTransport( fingerprint=self.fingerprint, methodname=resource["type"], - address=self.address, + address=resource["address"], port=resource["port"], arguments=resource.get("params", {}) ) diff --git a/bridgedb/rdsys.py b/bridgedb/rdsys.py index 15c5ce2..f90cf54 100644 --- a/bridgedb/rdsys.py +++ b/bridgedb/rdsys.py @@ -8,7 +8,7 @@ from twisted.internet.protocol import Protocol from twisted.web.client import Agent, FileBodyProducer from twisted.web.http_headers import Headers
-from bridgedb.bridges import Bridge +from bridgedb.bridges import Bridge, MalformedBridgeInfo
inter_message_delimiter = b"\r" @@ -58,11 +58,14 @@ class RdsysProtocol(Protocol):
for resource in jb[action][rtype]: bridge = Bridge() - bridge.updateFromResource(resource) + try: + bridge.updateFromResource(resource) + except MalformedBridgeInfo as e: + logging.warning("Got a malformed bridge: %s" % e) fn(bridge)
def connectionLost(self, reason): - logging.info("Connection lost with rdsys backend:", reason.getErrorMessage()) + logging.info("Connection lost with rdsys backend: %s" % reason) self.finished.callback(None)
tor-commits@lists.torproject.org