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

[tor-commits] [arm/master] fix: display control socket path in header panel



commit dc49b356cade11e38f0a826c6660b23883e4e99a
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Thu Aug 11 09:56:56 2011 -0700

    fix: display control socket path in header panel
    
    Replacing the 'Control Port (<authType>): <port>' entry in the header panel
    with 'Control Socket: <socketPath>' when connected via a control socket.
---
 src/cli/headerPanel.py |   31 ++++++++++++++++++-------------
 1 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/src/cli/headerPanel.py b/src/cli/headerPanel.py
index 0e8c018..2c32af8 100644
--- a/src/cli/headerPanel.py
+++ b/src/cli/headerPanel.py
@@ -51,7 +51,7 @@ class HeaderPanel(panel.Panel, threading.Thread):
   Top area contenting tor settings and system information. Stats are stored in
   the vals mapping, keys including:
     tor/  version, versionStatus, nickname, orPort, dirPort, controlPort,
-          exitPolicy, isAuthPassword (bool), isAuthCookie (bool),
+          socketPath, exitPolicy, isAuthPassword (bool), isAuthCookie (bool),
           orListenAddr, *address, *fingerprint, *flags, pid, startTime,
           *fdUsed, fdLimit, isFdLimitEstimate
     sys/  hostname, os, version
@@ -239,17 +239,21 @@ class HeaderPanel(panel.Panel, threading.Thread):
         includeControlPort = False
     
     if includeControlPort:
-      if self.vals["tor/isAuthPassword"]: authType = "password"
-      elif self.vals["tor/isAuthCookie"]: authType = "cookie"
-      else: authType = "open"
-      
-      if x + 19 + len(self.vals["tor/controlPort"]) + len(authType) <= leftWidth:
-        authColor = "red" if authType == "open" else "green"
-        self.addstr(1, x, ", Control Port (")
-        self.addstr(1, x + 16, authType, uiTools.getColor(authColor))
-        self.addstr(1, x + 16 + len(authType), "): %s" % self.vals["tor/controlPort"])
-      elif x + 16 + len(self.vals["tor/controlPort"]) <= leftWidth:
-        self.addstr(1, 0, ", Control Port: %s" % self.vals["tor/controlPort"])
+      if self.vals["tor/controlPort"] == "0":
+        # connected via a control socket
+        self.addstr(1, x, ", Control Socket: %s" % self.vals["tor/socketPath"])
+      else:
+        if self.vals["tor/isAuthPassword"]: authType = "password"
+        elif self.vals["tor/isAuthCookie"]: authType = "cookie"
+        else: authType = "open"
+        
+        if x + 19 + len(self.vals["tor/controlPort"]) + len(authType) <= leftWidth:
+          authColor = "red" if authType == "open" else "green"
+          self.addstr(1, x, ", Control Port (")
+          self.addstr(1, x + 16, authType, uiTools.getColor(authColor))
+          self.addstr(1, x + 16 + len(authType), "): %s" % self.vals["tor/controlPort"])
+        elif x + 16 + len(self.vals["tor/controlPort"]) <= leftWidth:
+          self.addstr(1, 0, ", Control Port: %s" % self.vals["tor/controlPort"])
     
     # Line 3 / Line 1 Right (system usage info)
     y, x = (0, leftWidth) if isWide else (2, 0)
@@ -474,7 +478,8 @@ class HeaderPanel(panel.Panel, threading.Thread):
       self.vals["tor/nickname"] = conn.getOption("Nickname", "")
       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/controlPort"] = conn.getOption("ControlPort", "0")
+      self.vals["tor/socketPath"] = conn.getOption("ControlSocket", "")
       self.vals["tor/isAuthPassword"] = conn.getOption("HashedControlPassword") != None
       self.vals["tor/isAuthCookie"] = conn.getOption("CookieAuthentication") == "1"
       

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits