[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r22625: {arm} change: dropping information from the header when not runnin (in arm/trunk: . interface interface/graphing util)



Author: atagar
Date: 2010-07-11 01:38:18 +0000 (Sun, 11 Jul 2010)
New Revision: 22625

Modified:
   arm/trunk/TODO
   arm/trunk/interface/graphing/bandwidthStats.py
   arm/trunk/interface/headerPanel.py
   arm/trunk/util/torTools.py
Log:
change: dropping information from the header when not running as a relay (not sure what to provide in a client-only context...)
fix: skipping bandwidth prepopulation if not running as a relay (caught by arma)
fix: caching that fingerprints will be unknown if orport is unset



Modified: arm/trunk/TODO
===================================================================
--- arm/trunk/TODO	2010-07-09 16:40:31 UTC (rev 22624)
+++ arm/trunk/TODO	2010-07-11 01:38:18 UTC (rev 22625)
@@ -23,6 +23,7 @@
           - fetch text via getinfo rather than reading directly?
               conn.get_info("config-text")
         [-] conn panel (for version 1.3.8)
+          - drop page entirely if being run as a client
           - check family connections to see if they're alive (VERSION cell
               handshake?)
           - fallback when pid or connection querying via pid is unavailable
@@ -103,6 +104,12 @@
     * connections aren't cleared when control port closes
 
 - Features / Site
+  * client use cases
+    * not sure what sort of information would be useful in the header (to
+      replace the orport, fingerprint, flags, etc)
+    * special page for client related information, such as ips of our client
+      circuits at the exit
+    * need to solicit for ideas on what would be most helpful to clients
   * check if batch getInfo/getOption calls provide much performance benefit
   * layout (css) bugs with site
       Revise to use 'em' for measurements and somehow stretch image's y-margin?

Modified: arm/trunk/interface/graphing/bandwidthStats.py
===================================================================
--- arm/trunk/interface/graphing/bandwidthStats.py	2010-07-09 16:40:31 UTC (rev 22624)
+++ arm/trunk/interface/graphing/bandwidthStats.py	2010-07-11 01:38:18 UTC (rev 22625)
@@ -60,9 +60,14 @@
     returns True if successful and False otherwise.
     """
     
+    # checks that this is a relay (if ORPort is unset, then skip)
+    conn = torTools.getConn()
+    orPort = conn.getOption("ORPort")
+    if orPort == "0": return
+    
     # gets the uptime (using the same parameters as the header panel to take
     # advantage of caching
-    conn, uptime = torTools.getConn(), None
+    uptime = None
     queryPid = conn.getMyPid()
     if queryPid:
       queryParam = ["%cpu", "rss", "%mem", "etime"]

Modified: arm/trunk/interface/headerPanel.py
===================================================================
--- arm/trunk/interface/headerPanel.py	2010-07-09 16:40:31 UTC (rev 22624)
+++ arm/trunk/interface/headerPanel.py	2010-07-11 01:38:18 UTC (rev 22625)
@@ -79,7 +79,8 @@
     """
     
     isWide = self.getParent().getmaxyx()[1] >= MIN_DUAL_COL_WIDTH
-    return 4 if isWide else 6
+    if self.vals["tor/orPort"]: return 4 if isWide else 6
+    else: return 3 if isWide else 4
   
   def draw(self, subwindow, width, height):
     self.valsLock.acquire()
@@ -112,15 +113,18 @@
       self.addstr(0, 43, uiTools.cropStr("Tor %s" % self.vals["tor/version"], contentSpace, 4))
     
     # Line 2 / Line 2 Left (tor ip/port information)
-    entry = ""
-    dirPortLabel = ", Dir Port: %s" % self.vals["tor/dirPort"] if self.vals["tor/dirPort"] != "0" else ""
-    for label in (self.vals["tor/nickname"], " - " + self.vals["tor/address"], ":" + self.vals["tor/orPort"], dirPortLabel):
-      if len(entry) + len(label) <= leftWidth: entry += label
-      else: break
+    if self.vals["tor/orPort"]:
+      # acting as a relay (we can assume certain parameters are set
+      entry = ""
+      dirPortLabel = ", Dir Port: %s" % self.vals["tor/dirPort"] if self.vals["tor/dirPort"] != "0" else ""
+      for label in (self.vals["tor/nickname"], " - " + self.vals["tor/address"], ":" + self.vals["tor/orPort"], dirPortLabel):
+        if len(entry) + len(label) <= leftWidth: entry += label
+        else: break
+    else:
+      # non-relay (client only)
+      # TODO: not sure what sort of stats to provide...
+      entry = "<red><b>Relaying Disabled</b></red>"
     
-    # strips off divider if nicknames undefined (happens if orport is unset)
-    if entry.startswith(" - "): entry = entry[3:]
-    
     if self.vals["tor/isAuthPassword"]: authType = "password"
     elif self.vals["tor/isAuthCookie"]: authType = "cookie"
     else: authType = "open"
@@ -147,47 +151,52 @@
       if start + len(label) <= rightWidth: self.addstr(y, x + start, label)
       else: break
     
-    # Line 4 / Line 2 Right (fingerprint)
-    y, x = (1, leftWidth) if isWide else (3, 0)
-    self.addstr(y, x, "fingerprint: %s" % self.vals["tor/fingerprint"])
-    
-    # Line 5 / Line 3 Left (flags)
-    if self._isTorConnected:
-      flagLine = "flags: "
-      for flag in self.vals["tor/flags"]:
-        flagColor = FLAG_COLORS[flag] if flag in FLAG_COLORS.keys() else "white"
-        flagLine += "<b><%s>%s</%s></b>, " % (flagColor, flag, flagColor)
+    if self.vals["tor/orPort"]:
+      # Line 4 / Line 2 Right (fingerprint)
+      y, x = (1, leftWidth) if isWide else (3, 0)
+      self.addstr(y, x, "fingerprint: %s" % self.vals["tor/fingerprint"])
       
-      if len(self.vals["tor/flags"]) > 0: flagLine = flagLine[:-2]
-      else: flagLine += "<b><cyan>none</cyan></b>"
+      # Line 5 / Line 3 Left (flags)
+      if self._isTorConnected:
+        flagLine = "flags: "
+        for flag in self.vals["tor/flags"]:
+          flagColor = FLAG_COLORS[flag] if flag in FLAG_COLORS.keys() else "white"
+          flagLine += "<b><%s>%s</%s></b>, " % (flagColor, flag, flagColor)
+        
+        if len(self.vals["tor/flags"]) > 0: flagLine = flagLine[:-2]
+        else: flagLine += "<b><cyan>none</cyan></b>"
+        
+        self.addfstr(2 if isWide else 4, 0, flagLine)
+      else:
+        statusTime = torTools.getConn().getStatus()[1]
+        statusTimeLabel = time.strftime("%H:%M %m/%d/%Y", time.localtime(statusTime))
+        self.addfstr(2 if isWide else 4, 0, "<b><red>Tor Disconnected</red></b> (%s)" % statusTimeLabel)
       
-      self.addfstr(2 if isWide else 4, 0, flagLine)
+      # Undisplayed / Line 3 Right (exit policy)
+      if isWide:
+        exitPolicy = self.vals["tor/exitPolicy"]
+        
+        # adds note when default exit policy is appended
+        if exitPolicy == None: exitPolicy = "<default>"
+        elif not exitPolicy.endswith((" *:*", " *")): exitPolicy += ", <default>"
+        
+        # color codes accepts to be green, rejects to be red, and default marker to be cyan
+        isSimple = len(exitPolicy) > rightWidth - 13
+        policies = exitPolicy.split(", ")
+        for i in range(len(policies)):
+          policy = policies[i].strip()
+          displayedPolicy = policy.replace("accept", "").replace("reject", "").strip() if isSimple else policy
+          if policy.startswith("accept"): policy = "<green><b>%s</b></green>" % displayedPolicy
+          elif policy.startswith("reject"): policy = "<red><b>%s</b></red>" % displayedPolicy
+          elif policy.startswith("<default>"): policy = "<cyan><b>%s</b></cyan>" % displayedPolicy
+          policies[i] = policy
+        
+        self.addfstr(2, leftWidth, "exit policy: %s" % ", ".join(policies))
     else:
-      statusTime = torTools.getConn().getStatus()[1]
-      statusTimeLabel = time.strftime("%H:%M %m/%d/%Y", time.localtime(statusTime))
-      self.addfstr(2 if isWide else 4, 0, "<b><red>Tor Disconnected</red></b> (%s)" % statusTimeLabel)
+      # Client only
+      # TODO: not sure what information to provide here...
+      pass
     
-    # Undisplayed / Line 3 Right (exit policy)
-    if isWide:
-      exitPolicy = self.vals["tor/exitPolicy"]
-      
-      # adds note when default exit policy is appended
-      if exitPolicy == None: exitPolicy = "<default>"
-      elif not exitPolicy.endswith((" *:*", " *")): exitPolicy += ", <default>"
-      
-      # color codes accepts to be green, rejects to be red, and default marker to be cyan
-      isSimple = len(exitPolicy) > rightWidth - 13
-      policies = exitPolicy.split(", ")
-      for i in range(len(policies)):
-        policy = policies[i].strip()
-        displayedPolicy = policy.replace("accept", "").replace("reject", "").strip() if isSimple else policy
-        if policy.startswith("accept"): policy = "<green><b>%s</b></green>" % displayedPolicy
-        elif policy.startswith("reject"): policy = "<red><b>%s</b></red>" % displayedPolicy
-        elif policy.startswith("<default>"): policy = "<cyan><b>%s</b></cyan>" % displayedPolicy
-        policies[i] = policy
-      
-      self.addfstr(2, leftWidth, "exit policy: %s" % ", ".join(policies))
-    
     self._isLastDrawWide = isWide
     self._isChanged = False
     self.valsLock.release()
@@ -268,12 +277,15 @@
       self.vals["tor/version"] = conn.getInfo("version", "Unknown").split()[0]
       self.vals["tor/versionStatus"] = conn.getInfo("status/version/current", "Unknown")
       self.vals["tor/nickname"] = conn.getOption("Nickname", "")
-      self.vals["tor/orPort"] = conn.getOption("ORPort", "")
+      self.vals["tor/orPort"] = conn.getOption("ORPort", "0")
       self.vals["tor/dirPort"] = conn.getOption("DirPort", "0")
       self.vals["tor/controlPort"] = conn.getOption("ControlPort", "")
       self.vals["tor/isAuthPassword"] = conn.getOption("HashedControlPassword") != None
       self.vals["tor/isAuthCookie"] = conn.getOption("CookieAuthentication") == "1"
       
+      # orport is reported as zero if unset
+      if self.vals["tor/orPort"] == "0": self.vals["tor/orPort"] = ""
+      
       # overwrite address if ORListenAddress is set (and possibly orPort too)
       self.vals["tor/address"] = "Unknown"
       listenAddr = conn.getOption("ORListenAddress")

Modified: arm/trunk/util/torTools.py
===================================================================
--- arm/trunk/util/torTools.py	2010-07-09 16:40:31 UTC (rev 22624)
+++ arm/trunk/util/torTools.py	2010-07-11 01:38:18 UTC (rev 22625)
@@ -844,9 +844,12 @@
             if bwValue.isdigit(): result = int(bwValue)
             break
       elif key == "fingerprint":
-        # fingerprints are kept until sighup if set (most likely not even a
-        # setconf can change it since it's in the data directory)
-        result = self.getInfo("fingerprint")
+        # Fingerprints are kept until sighup if set (most likely not even a
+        # setconf can change it since it's in the data directory). If orport is
+        # unset then no fingerprint will be set.
+        orPort = self.getOption("ORPort", "0")
+        if orPort == "0": result = UNKNOWN
+        else: result = self.getInfo("fingerprint")
       elif key == "flags":
         for line in self.getMyNetworkStatus([]):
           if line.startswith("s "):