[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r22559: {arm} change: attempting to reduce GETINFO call volume from the he (in arm/trunk: . interface interface/graphing util)
Author: atagar
Date: 2010-06-27 03:53:55 +0000 (Sun, 27 Jun 2010)
New Revision: 22559
Modified:
arm/trunk/TODO
arm/trunk/interface/connPanel.py
arm/trunk/interface/controller.py
arm/trunk/interface/graphing/bandwidthStats.py
arm/trunk/interface/headerPanel.py
arm/trunk/util/torTools.py
Log:
change: attempting to reduce GETINFO call volume from the header panel
fix: wasn't accounting for the ORListenAddress correctly
Modified: arm/trunk/TODO
===================================================================
--- arm/trunk/TODO 2010-06-26 22:27:20 UTC (rev 22558)
+++ arm/trunk/TODO 2010-06-27 03:53:55 UTC (rev 22559)
@@ -10,8 +10,6 @@
bugs are being fixed while refactoring.
[X] header panel
[ ] graph panel
- - include observed bandwidth
- http://torstatus.blutmagie.de/router_detail.php?FP=a7569a83b5706ab1b1a9cb52eff7d2d32e4553eb
- prepopulate bandwidth graph with contents of state file
Open questions:
- How frequently are the bandwidth values in the state file
Modified: arm/trunk/interface/connPanel.py
===================================================================
--- arm/trunk/interface/connPanel.py 2010-06-26 22:27:20 UTC (rev 22558)
+++ arm/trunk/interface/connPanel.py 2010-06-27 03:53:55 UTC (rev 22559)
@@ -216,6 +216,7 @@
self.clientConnectionLock.release()
# when consensus changes update fingerprint mappings
+ # TODO: should also be taking NS events into account
def new_consensus_event(self, event):
self.orconnStatusCacheValid = False
self.fingerprintLookupCache.clear()
Modified: arm/trunk/interface/controller.py
===================================================================
--- arm/trunk/interface/controller.py 2010-06-26 22:27:20 UTC (rev 22558)
+++ arm/trunk/interface/controller.py 2010-06-27 03:53:55 UTC (rev 22559)
@@ -272,11 +272,12 @@
events = dict([(eventType, None) for eventType in events])
# add mandatory events (those needed for arm functionaity)
- reqEvents = {"BW": "(bandwidth graph won't function)"}
+ reqEvents = {"BW": "(bandwidth graph won't function)",
+ "NEWDESC": "(information related to descriptors will grow stale)",
+ "NS": "(information related to the consensus will grow stale)",
+ "NEWCONSENSUS": "(information related to the consensus will grow stale)"}
if not isBlindMode:
- reqEvents["NEWDESC"] = "(connections listing can't register consensus changes)"
- reqEvents["NEWCONSENSUS"] = "(connections listing can't register consensus changes)"
reqEvents["CIRC"] = "(may cause issues in identifying client connections)"
for eventType, msg in reqEvents.items():
Modified: arm/trunk/interface/graphing/bandwidthStats.py
===================================================================
--- arm/trunk/interface/graphing/bandwidthStats.py 2010-06-26 22:27:20 UTC (rev 22558)
+++ arm/trunk/interface/graphing/bandwidthStats.py 2010-06-27 03:53:55 UTC (rev 22559)
@@ -47,7 +47,9 @@
return self.observedBandwidth
def new_desc_event(self, event):
- self._parseDescriptors()
+ myFingerprint = torTools.getConn().getFingerprint()
+ if not myFingerprint or myFingerprint in event.idlist:
+ self._parseDescriptors()
def _parseDescriptors(self):
conn = torTools.getConn()
Modified: arm/trunk/interface/headerPanel.py
===================================================================
--- arm/trunk/interface/headerPanel.py 2010-06-26 22:27:20 UTC (rev 22558)
+++ arm/trunk/interface/headerPanel.py 2010-06-27 03:53:55 UTC (rev 22559)
@@ -271,6 +271,17 @@
self.vals["tor/isAuthPassword"] = conn.getOption("HashedControlPassword") != None
self.vals["tor/isAuthCookie"] = conn.getOption("CookieAuthentication") == "1"
+ # overwrite address if ORListenAddress is set (and possibly orPort too)
+ self.vals["tor/address"] = "Unknown"
+ listenAddr = conn.getOption("ORListenAddress")
+ if listenAddr:
+ if ":" in listenAddr:
+ # both ip and port overwritten
+ self.vals["tor/address"] = listenAddr[:listenAddr.find(":")]
+ self.vals["tor/orPort"] = listenAddr[listenAddr.find(":") + 1:]
+ else:
+ self.vals["tor/address"] = listenAddr
+
# fetch exit policy (might span over multiple lines)
policyEntries = []
for exitPolicy in conn.getOption("ExitPolicy", [], True):
@@ -287,7 +298,6 @@
self.vals["ps/pid"] = pid if pid else ""
# reverts volatile parameters to defaults
- self.vals["tor/address"] = "Unknown"
self.vals["tor/fingerprint"] = "Unknown"
self.vals["tor/flags"] = []
self.vals["ps/%cpu"] = "0"
@@ -297,26 +307,21 @@
# sets volatile parameters
volatile = {}
- volatile["tor/address"] = conn.getInfo("address", self.vals["tor/address"])
- volatile["tor/fingerprint"] = conn.getInfo("fingerprint", self.vals["tor/fingerprint"])
- # overwrite address if ORListenAddress is set (and possibly orPort too)
- listenAddr = conn.getOption("ORListenAddress")
- if listenAddr:
- if ":" in listenAddr:
- # both ip and port overwritten
- volatile["address"] = listenAddr[:listenAddr.find(":")]
- volatile["orPort"] = listenAddr[listenAddr.find(":") + 1:]
- else:
- volatile["address"] = listenAddr
+ # TODO: This can change, being reported by STATUS_SERVER -> EXTERNAL_ADDRESS
+ # events. Introduce caching via torTools?
+ if self.vals["tor/address"] == "Unknown":
+ volatile["tor/address"] = conn.getInfo("address", self.vals["tor/address"])
+ volatile["tor/fingerprint"] = conn.getFingerprint(self.vals["tor/fingerprint"])
+
# sets flags
- if self.vals["tor/fingerprint"] != "Unknown":
+ nsEntry = conn.getNetworkStatus()
+ if nsEntry:
# network status contains a couple of lines, looking like:
# r caerSidi p1aag7VwarGxqctS7/fS0y5FU+s 9On1TRGCEpljszPpJR1hKqlzaY8 2010-05-26 09:26:06 76.104.132.98 9001 0
# s Fast HSDir Named Running Stable Valid
- nsResults = conn.getInfo("ns/id/%s" % self.vals["tor/fingerprint"], "").split("\n")
- if len(nsResults) >= 2: volatile["tor/flags"] = nsResults[1][2:].split()
+ if len(nsEntry) >= 2: volatile["tor/flags"] = nsEntry[1][2:].split()
# ps derived stats
psParams = ["%cpu", "rss", "%mem", "etime"]
Modified: arm/trunk/util/torTools.py
===================================================================
--- arm/trunk/util/torTools.py 2010-06-26 22:27:20 UTC (rev 22558)
+++ arm/trunk/util/torTools.py 2010-06-27 03:53:55 UTC (rev 22559)
@@ -262,6 +262,7 @@
self._isReset = False # internal flag for tracking resets
self._status = TOR_CLOSED # current status of the attached control port
self._statusTime = 0 # unix timestamp for the duration of the status
+ self._myNsEntry = None # network status entry for this relay (none if unset or possibly changed)
# cached information static for a connection (None if unset, "UNKNOWN" if
# unable to be determined)
@@ -418,6 +419,39 @@
if not suppressExc and raisedExc: raise raisedExc
else: return result
+ def getFingerprint(self, default = None):
+ """
+ Provides the fingerprint for this relay.
+
+ Arguments:
+ default - result if the query fails
+ """
+
+ # TODO: figure out what can cause the fingerprint to change so this can be cached
+ myFingerprint = self.getInfo("fingerprint")
+
+ if myFingerprint: return myFingerprint
+ else: return default
+
+ def getNetworkStatus(self):
+ """
+ Provides the network status entry for this relay if available (otherwise
+ provides None).
+ """
+
+ if self._myNsEntry: return self._myNsEntry
+
+ self.connLock.acquire()
+
+ myFingerprint = self.getFingerprint()
+ if myFingerprint:
+ nsResults = self.getInfo("ns/id/%s" % myFingerprint)
+ if nsResults: self._myNsEntry = nsResults.split("\n")
+
+ self.connLock.release()
+
+ return self._myNsEntry
+
def getPid(self):
"""
Provides the pid of the attached tor process (None if no controller exists
@@ -654,6 +688,20 @@
thread.start_new_thread(self._notifyStatusListeners, (TOR_INIT,))
+ def ns_event(self, event):
+ # TODO: Not sure if idhash or orhash is the relay's fingerprint
+ #myFingerprint = self.getFingerprint()
+ #if myFingerprint:
+ # for ns in event.nslist:
+ # if ns.idhash == myFingerprint:
+ # self._myNsEntry = None
+ # return
+
+ self._myNsEntry = None
+
+ def new_consensus_event(self, event):
+ self._myNsEntry = None
+
def _notifyStatusListeners(self, eventType):
"""
Sends a notice to all current listeners that a given change in tor's