[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [arm/master] Exposing ip -> (port, fp) mappings in tor util
commit 5ef37f23c8ae7270a1ed773487208ce7f81007e1
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date: Wed Sep 7 10:00:29 2011 -0700
Exposing ip -> (port, fp) mappings in tor util
Providing the cached relay locale mappings in the torTools util. This is
generally useful information and gonna be needed to query the locales of all
exits.
---
src/util/torTools.py | 30 ++++++++++++++++++++++++++++++
1 files changed, 30 insertions(+), 0 deletions(-)
diff --git a/src/util/torTools.py b/src/util/torTools.py
index adc175a..8567158 100644
--- a/src/util/torTools.py
+++ b/src/util/torTools.py
@@ -1288,6 +1288,36 @@ class Controller(TorCtl.PostEventListener):
return result
+ def getAllRelayAddresses(self, default = {}):
+ """
+ Provides a mapping of...
+ Relay IP Address -> [(ORPort, Fingerprint)...]
+
+ for all relays currently in the cached consensus.
+
+ Arguments:
+ default - value returned if the query fails
+ """
+
+ self.connLock.acquire()
+
+ result = default
+
+ if self.isAlive():
+ # check both if the cached mappings are unset or blank
+ if not self._fingerprintMappings:
+ self._fingerprintMappings = self._getFingerprintMappings()
+
+ # Make a shallow copy of the results. This doesn't protect the internal
+ # listings, but good enough for the moment.
+ # TODO: change the [(port, fingerprint)...] lists to tuples?
+ if self._fingerprintMappings != {}:
+ result = dict(self._fingerprintMappings)
+
+ self.connLock.release()
+
+ return result
+
def getNicknameFingerprint(self, relayNickname):
"""
Provides the fingerprint associated with the given relay. This provides
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits