Author: atagar
Date: 2011-04-03 04:16:00 +0000 (Sun, 03 Apr 2011)
New Revision: 24541
Modified:
arm/trunk/src/interface/connections/connEntry.py
Log:
Only flagging inbound connections as possibly being private if we're a guard or bridge.
Modified: arm/trunk/src/interface/connections/connEntry.py
===================================================================
--- arm/trunk/src/interface/connections/connEntry.py 2011-04-03 04:00:48 UTC (rev 24540)
+++ arm/trunk/src/interface/…
[View More]connections/connEntry.py 2011-04-03 04:16:00 UTC (rev 24541)
@@ -361,12 +361,13 @@
myType = self.getType()
if myType == Category.INBOUND:
- # if the connection doesn't belong to a known relay then it might be
- # client traffic
+ # if we're a guard or bridge and the connection doesn't belong to a
+ # known relay then it might be client traffic
conn = torTools.getConn()
- allMatches = conn.getRelayFingerprint(self.foreign.getIpAddr(), getAllMatches = True)
- return allMatches == []
+ if "Guard" in conn.getMyFlags() or conn.getOption("BridgeRelay") == "1":
+ allMatches = conn.getRelayFingerprint(self.foreign.getIpAddr(), getAllMatches = True)
+ return allMatches == []
elif myType == Category.EXIT:
# DNS connections exiting us aren't private (since they're hitting our
# resolvers). Everything else, however, is.
[View Less]
Author: atagar
Date: 2011-04-03 04:00:48 +0000 (Sun, 03 Apr 2011)
New Revision: 24540
Modified:
arm/trunk/armrc.sample
arm/trunk/src/util/torTools.py
Log:
Giving a warning and prematurely aborting geoip lookups when the database is unavailble.
Modified: arm/trunk/armrc.sample
===================================================================
--- arm/trunk/armrc.sample 2011-04-02 23:51:15 UTC (rev 24539)
+++ arm/trunk/armrc.sample 2011-04-03 04:00:48 UTC (rev 24540)
@@ -271,6 +271,7 @@…
[View More]
log.cursesColorSupport INFO
log.bsdJailFound INFO
log.unknownBsdJailId WARN
+log.geoipUnavailable WARN
log.stats.failedProcResolution DEBUG
log.stats.procResolutionFailover INFO
log.stats.failedPsResolution INFO
Modified: arm/trunk/src/util/torTools.py
===================================================================
--- arm/trunk/src/util/torTools.py 2011-04-02 23:51:15 UTC (rev 24539)
+++ arm/trunk/src/util/torTools.py 2011-04-03 04:00:48 UTC (rev 24540)
@@ -90,6 +90,10 @@
"NS": "information related to the consensus will grow stale",
"NEWCONSENSUS": "information related to the consensus will grow stale"}
+# number of sequential attempts before we decide that the Tor geoip database
+# is unavailable
+GEOIP_FAILURE_THRESHOLD = 5
+
# provides int -> str mappings for torctl event runlevels
TORCTL_RUNLEVELS = dict([(val, key) for (key, val) in TorUtil.loglevels.items()])
@@ -310,6 +314,9 @@
# directs TorCtl to notify us of events
TorUtil.logger = self
TorUtil.loglevel = "DEBUG"
+
+ # tracks the number of sequential geoip lookup failures
+ self.geoipFailureCount = 0
def init(self, conn=None):
"""
@@ -445,6 +452,8 @@
self.connLock.acquire()
+ isGeoipRequest = param.startswith("ip-to-country/")
+
# checks if this is an arg caching covers
isCacheArg = param in CACHE_ARGS
@@ -462,13 +471,23 @@
if isCacheArg and cachedValue:
result = cachedValue
isFromCache = True
+ elif isGeoipRequest and self.geoipFailureCount == GEOIP_FAILURE_THRESHOLD:
+ # the geoip database aleady looks to be unavailable - abort the request
+ raisedExc = TorCtl.ErrorReply("Tor geoip database is unavailable.")
else:
try:
getInfoVal = self.conn.get_info(param)[param]
if getInfoVal != None: result = getInfoVal
+ if isGeoipRequest: self.geoipFailureCount = 0
except (socket.error, TorCtl.ErrorReply, TorCtl.TorCtlClosed), exc:
if type(exc) == TorCtl.TorCtlClosed: self.close()
raisedExc = exc
+
+ if isGeoipRequest:
+ self.geoipFailureCount += 1
+
+ if self.geoipFailureCount == GEOIP_FAILURE_THRESHOLD:
+ log.log(CONFIG["log.geoipUnavailable"], "Tor geoip database is unavailable.")
if isCacheArg and result and not isFromCache:
self._cachedParam[param] = result
[View Less]
Author: atagar
Date: 2011-04-02 23:00:11 +0000 (Sat, 02 Apr 2011)
New Revision: 24538
Modified:
arm/trunk/src/interface/connections/connPanel.py
Log:
Freezing connection display when tor stops.
Modified: arm/trunk/src/interface/connections/connPanel.py
===================================================================
--- arm/trunk/src/interface/connections/connPanel.py 2011-04-02 22:42:48 UTC (rev 24537)
+++ arm/trunk/src/interface/connections/connPanel.py 2011-04-02 23:00:11 UTC (rev …
[View More]24538)
@@ -54,6 +54,7 @@
self._showDetails = False # presents the details panel if true
self._lastUpdate = -1 # time the content was last revised
+ self._isTorRunning = True # indicates if tor is currently running or not
self._isPaused = True # prevents updates if true
self._pauseTime = None # time when the panel was paused
self._halt = False # terminates thread if true
@@ -77,7 +78,27 @@
for entry in self._entries:
if isinstance(entry, connEntry.ConnectionEntry):
entry.getLines()[0].isInitialConnection = True
+
+ # listens for when tor stops so we know to stop reflecting changes
+ torTools.getConn().addStatusListener(self.torStateListener)
+ def torStateListener(self, conn, eventType):
+ """
+ Freezes the connection contents when Tor stops.
+
+ Arguments:
+ conn - tor controller
+ eventType - type of event detected
+ """
+
+ self._isTorRunning = eventType == torTools.State.INIT
+
+ if self._isPaused or not self._isTorRunning:
+ if not self._pauseTime: self._pauseTime = time.time()
+ else: self._pauseTime = None
+
+ self.redraw(True)
+
def setPaused(self, isPause):
"""
If true, prevents the panel from updating.
@@ -86,7 +107,8 @@
if not self._isPaused == isPause:
self._isPaused = isPause
- if isPause: self._pauseTime = time.time()
+ if isPause or not self._isTorRunning:
+ if not self._pauseTime: self._pauseTime = time.time()
else: self._pauseTime = None
# redraws so the display reflects any changes between the last update
@@ -151,7 +173,7 @@
while not self._halt:
currentTime = time.time()
- if self._isPaused or currentTime - lastDraw < self._config["features.connection.refreshRate"]:
+ if self._isPaused or not self._isTorRunning or currentTime - lastDraw < self._config["features.connection.refreshRate"]:
self._cond.acquire()
if not self._halt: self._cond.wait(0.2)
self._cond.release()
[View Less]