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

[tor-commits] [nyx/master] Drop get_type() from connection lines



commit 7d397f9da1fc01775b4e012b34187349f75fc930
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Sun Aug 30 11:09:16 2015 -0700

    Drop get_type() from connection lines
    
    The connection lines proxies through to the entry. External callers should (and
    are) calling on the entry, and the lines can use their own entry reference.
---
 nyx/connections/circ_entry.py |    4 ++--
 nyx/connections/conn_entry.py |   19 ++++++++-----------
 nyx/connections/entries.py    |    4 ++--
 3 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/nyx/connections/circ_entry.py b/nyx/connections/circ_entry.py
index 673777d..f396385 100644
--- a/nyx/connections/circ_entry.py
+++ b/nyx/connections/circ_entry.py
@@ -69,7 +69,7 @@ class CircHeaderLine(conn_entry.ConnectionLine):
 
   def get_details(self, width):
     if not self.is_built:
-      detail_format = (curses.A_BOLD, conn_entry.CATEGORY_COLOR[self.get_type()])
+      detail_format = (curses.A_BOLD, conn_entry.CATEGORY_COLOR[self._entry.get_type()])
       return [('Building Circuit...', detail_format)]
     else:
       return conn_entry.ConnectionLine.get_details(self, width)
@@ -127,7 +127,7 @@ class CircLine(conn_entry.ConnectionLine):
     return entries.ConnectionPanelLine.get_listing_entry(self, width, current_time, listing_type)
 
   def _get_listing_entry(self, width, current_time, listing_type):
-    line_format = nyx.util.ui_tools.get_color(conn_entry.CATEGORY_COLOR[self.get_type()])
+    line_format = nyx.util.ui_tools.get_color(conn_entry.CATEGORY_COLOR[self._entry.get_type()])
 
     # The required widths are the sum of the following:
     # initial space (1 character)
diff --git a/nyx/connections/conn_entry.py b/nyx/connections/conn_entry.py
index 13aaadf..40a626f 100644
--- a/nyx/connections/conn_entry.py
+++ b/nyx/connections/conn_entry.py
@@ -82,7 +82,7 @@ class ConnectionLine(entries.ConnectionPanelLine):
     Provides the fingerprint of this relay.
     """
 
-    if self.get_type() in (Category.OUTBOUND, Category.CIRCUIT, Category.DIRECTORY, Category.EXIT):
+    if self._entry.get_type() in (Category.OUTBOUND, Category.CIRCUIT, Category.DIRECTORY, Category.EXIT):
       my_fingerprint = nyx.util.tracker.get_consensus_tracker().get_relay_fingerprint(self.connection.remote_address, self.connection.remote_port)
       return my_fingerprint if my_fingerprint else default
     else:
@@ -141,7 +141,7 @@ class ConnectionLine(entries.ConnectionPanelLine):
     return my_listing
 
   def _get_listing_entry(self, width, current_time, listing_type):
-    entry_type = self.get_type()
+    entry_type = self._entry.get_type()
 
     # Lines are split into the following components in reverse:
     # init gap - " "
@@ -172,12 +172,9 @@ class ConnectionLine(entries.ConnectionPanelLine):
       width - available space to display in
     """
 
-    detail_format = (curses.A_BOLD, CATEGORY_COLOR[self.get_type()])
+    detail_format = (curses.A_BOLD, CATEGORY_COLOR[self._entry.get_type()])
     return [(line, detail_format) for line in self._get_detail_content(width)]
 
-  def get_type(self):
-    return self._entry.get_type()
-
   def get_etc_content(self, width, listing_type):
     """
     Provides the optional content for the connection.
@@ -189,8 +186,8 @@ class ConnectionLine(entries.ConnectionPanelLine):
 
     # for applications show the command/pid
 
-    if self.get_type() in (Category.SOCKS, Category.HIDDEN, Category.CONTROL):
-      port = self.connection.local_port if self.get_type() == Category.HIDDEN else self.connection.remote_port
+    if self._entry.get_type() in (Category.SOCKS, Category.HIDDEN, Category.CONTROL):
+      port = self.connection.local_port if self._entry.get_type() == Category.HIDDEN else self.connection.remote_port
 
       try:
         process = nyx.util.tracker.get_port_usage_tracker().fetch(port)
@@ -270,7 +267,7 @@ class ConnectionLine(entries.ConnectionPanelLine):
     """
 
     controller = tor_controller()
-    my_type = self.get_type()
+    my_type = self._entry.get_type()
     destination_address = self.get_destination_label(26, include_locale = True)
 
     # The required widths are the sum of the following:
@@ -541,7 +538,7 @@ class ConnectionLine(entries.ConnectionPanelLine):
 
     # the port and port derived data can be hidden by config or without include_port
 
-    include_port = self.include_port and (CONFIG['features.connection.showExitPort'] or self.get_type() != Category.EXIT)
+    include_port = self.include_port and (CONFIG['features.connection.showExitPort'] or self._entry.get_type() != Category.EXIT)
 
     # destination of the connection
 
@@ -555,7 +552,7 @@ class ConnectionLine(entries.ConnectionPanelLine):
     if len(destination_address) + 5 <= max_length:
       space_available = max_length - len(destination_address) - 3
 
-      if self.get_type() == Category.EXIT and include_port:
+      if self._entry.get_type() == Category.EXIT and include_port:
         purpose = connection.port_usage(self.connection.remote_port)
 
         if purpose:
diff --git a/nyx/connections/entries.py b/nyx/connections/entries.py
index fb49f98..b30ae43 100644
--- a/nyx/connections/entries.py
+++ b/nyx/connections/entries.py
@@ -4,6 +4,8 @@ entry itself (ie, Tor connection, client circuit, etc) and the lines it
 consists of in the listing.
 """
 
+import nyx.util.tracker
+
 from nyx.util import tor_controller
 
 from stem.control import Listener
@@ -83,7 +85,6 @@ class Entry(object):
     """
 
     import nyx.connections.conn_entry
-    import nyx.util.tracker
 
     if not CONFIG['features.connection.showIps']:
       return True
@@ -216,7 +217,6 @@ class ConnectionPanelLine:
 
 
 def get_type(connection):
-  import nyx.util.tracker
   from nyx.connections.conn_entry import Category
   controller = tor_controller()
 



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