[tor-commits] [arm/release] Tor shutdown indicator when in client mode

atagar at torproject.org atagar at torproject.org
Sun Jul 17 06:08:26 UTC 2011


commit 8fd556d502e42c33eaff038b6a6b0d2b99523da3
Author: Damian Johnson <atagar at torproject.org>
Date:   Fri Jun 17 09:46:49 2011 -0700

    Tor shutdown indicator when in client mode
    
    When we're running as a client the ports line is replaced with the shutdown
    message when tor is no longer running. Also changing the "Relaying Disabled"
    indicator to be cyan rather than bold red since this isn't really a problem.
---
 src/cli/headerPanel.py |   40 ++++++++++++++++++++++++----------------
 1 files changed, 24 insertions(+), 16 deletions(-)

diff --git a/src/cli/headerPanel.py b/src/cli/headerPanel.py
index b5b3826..145e75b 100644
--- a/src/cli/headerPanel.py
+++ b/src/cli/headerPanel.py
@@ -183,7 +183,7 @@ class HeaderPanel(panel.Panel, threading.Thread):
       self.addstr(0, 43, uiTools.cropStr("Tor %s" % self.vals["tor/version"], contentSpace, 4))
     
     # Line 2 / Line 2 Left (tor ip/port information)
-    x = 0
+    x, includeControlPort = 0, True
     if self.vals["tor/orPort"]:
       myAddress = "Unknown"
       if self.vals["tor/orListenAddr"]: myAddress = self.vals["tor/orListenAddr"]
@@ -198,21 +198,29 @@ class HeaderPanel(panel.Panel, threading.Thread):
         else: break
     else:
       # non-relay (client only)
-      # TODO: not sure what sort of stats to provide...
-      self.addstr(1, x, "Relaying Disabled", curses.A_BOLD | uiTools.getColor("red"))
-      x += 17
-    
-    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._isTorConnected:
+        self.addstr(1, x, "Relaying Disabled", uiTools.getColor("cyan"))
+        x += 17
+      else:
+        statusTime = torTools.getConn().getStatus()[1]
+        statusTimeLabel = time.strftime("%H:%M %m/%d/%Y", time.localtime(statusTime))
+        self.addstr(1, x, "Tor Disconnected", curses.A_BOLD | uiTools.getColor("red"))
+        self.addstr(1, x + 16, " (%s, press r to reconnect)" % statusTimeLabel)
+        x += 41 + len(statusTimeLabel)
+        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"])
     
     # Line 3 / Line 1 Right (system usage info)
     y, x = (0, leftWidth) if isWide else (2, 0)





More information about the tor-commits mailing list