[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [bridgedb/master] Catch potential KeyErrors on bridge ID lookups in bridgedb.Main.
commit 23f401d5e015ebfb283df1a86e82540c1507083d
Author: Isis Lovecruft <isis@xxxxxxxxxxxxxx>
Date: Tue Nov 5 06:00:48 2013 +0000
Catch potential KeyErrors on bridge ID lookups in bridgedb.Main.
We should catch the KeyError here, as sometimes this loop gets a bridge ID
from an extra-info descriptor and tries to lookup the bridge, causing a
KeyError on the lookup.
* ADD try/except wrapper to catch KeyErrors on looking up bridges by ID in
the bridges dict in bridgedb.Main.load().
---
lib/bridgedb/Main.py | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/lib/bridgedb/Main.py b/lib/bridgedb/Main.py
index 5479d6a..29d457b 100644
--- a/lib/bridgedb/Main.py
+++ b/lib/bridgedb/Main.py
@@ -136,12 +136,17 @@ def load(cfg, splitter, clear=False):
f = open(filename, 'r')
for transport in Bridges.parseExtraInfoFile(f):
ID, method_name, address, port, argdict = transport
- if bridges[ID].running:
- logging.debug(" Appending transport to running bridge")
- bridgePT = Bridges.PluggableTransport(
- bridges[ID], method_name, address, port, argdict)
- bridges[ID].transports.append(bridgePT)
- assert bridges[ID].transports, "We added a transport but it disappeared!"
+ try:
+ if bridges[ID].running:
+ logging.debug(" Appending transport to running bridge")
+ bridgePT = Bridges.PluggableTransport(
+ bridges[ID], method_name, address, port, argdict)
+ bridges[ID].transports.append(bridgePT)
+ assert bridges[ID].transports, \
+ "We added a transport but it disappeared!"
+ except KeyError as error:
+ logging.error("Could not find bridge with fingerprint '%s'."
+ % Bridges.toHex(ID))
logging.debug("Closing extra-info document")
f.close()
if hasattr(cfg, "COUNTRY_BLOCK_FILE"):
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits