[tor-commits] [nyx/master] Drop expanded addresses

atagar at torproject.org atagar at torproject.org
Tue Sep 22 17:08:41 UTC 2015


commit 89d2e97dcefc8af51200e52128fb909fc6c49771
Author: Damian Johnson <atagar at torproject.org>
Date:   Sat Sep 5 09:52:20 2015 -0700

    Drop expanded addresses
    
    When we have a lot of space we showed three addresses of the form
    '(local) => (externally visible) => (remote)'...
    
      192.168.0.20:56088     -->  174.21.33.26:56088     -->  85.114.132.36:9001
    
    Nice idea but it's confusing as hell for users. Hell, even I didn't know what
    these were until I looked at the code. Keeping it simple and just showing the
    important internal/external address.
---
 nyx/connections/circ_entry.py |    4 ++--
 nyx/connections/conn_entry.py |   41 +++--------------------------------------
 2 files changed, 5 insertions(+), 40 deletions(-)

diff --git a/nyx/connections/circ_entry.py b/nyx/connections/circ_entry.py
index 84e5b2b..920d599 100644
--- a/nyx/connections/circ_entry.py
+++ b/nyx/connections/circ_entry.py
@@ -46,7 +46,7 @@ class CircHeaderLine(conn_entry.ConnectionLine):
       self.is_built = False
       self._remote_fingerprint = None
 
-    conn_entry.ConnectionLine.__init__(self, entry, nyx.util.tracker.Connection(to_unix_time(circ.created), False, '127.0.0.1', 0, exit_address, exit_port, 'tcp'), False, False)
+    conn_entry.ConnectionLine.__init__(self, entry, nyx.util.tracker.Connection(to_unix_time(circ.created), False, '127.0.0.1', 0, exit_address, exit_port, 'tcp'), include_port = False)
     self.circuit = circ
 
   def get_fingerprint(self, default = None):
@@ -92,7 +92,7 @@ class CircLine(conn_entry.ConnectionLine):
 
   def __init__(self, entry, circ, fingerprint):
     relay_ip, relay_port = nyx.util.tracker.get_consensus_tracker().get_relay_address(fingerprint, ('192.168.0.1', 0))
-    conn_entry.ConnectionLine.__init__(self, entry, nyx.util.tracker.Connection(to_unix_time(circ.created), False, '127.0.0.1', 0, relay_ip, relay_port, 'tcp'), False)
+    conn_entry.ConnectionLine.__init__(self, entry, nyx.util.tracker.Connection(to_unix_time(circ.created), False, '127.0.0.1', 0, relay_ip, relay_port, 'tcp'), include_port = False)
     self._fingerprint = fingerprint
     self._is_last = False
 
diff --git a/nyx/connections/conn_entry.py b/nyx/connections/conn_entry.py
index d76808d..3ed78a9 100644
--- a/nyx/connections/conn_entry.py
+++ b/nyx/connections/conn_entry.py
@@ -37,7 +37,7 @@ class ConnectionLine(object):
   Display component of the ConnectionEntry.
   """
 
-  def __init__(self, entry, conn, include_port=True, include_expanded_addresses=True):
+  def __init__(self, entry, conn, include_port = True):
     self._entry = entry
     self.connection = conn
 
@@ -45,7 +45,6 @@ class ConnectionLine(object):
     # information if true
 
     self.include_port = include_port
-    self.include_expanded_addresses = include_expanded_addresses
 
   def get_listing_prefix(self):
     """
@@ -262,19 +261,10 @@ class ConnectionLine(object):
 
     if listing_type == nyx.connection_panel.Listing.IP_ADDRESS:
       my_external_address = controller.get_info('address', self.connection.local_address)
-      address_differ = my_external_address != self.connection.local_address
 
-      # Expanding doesn't make sense, if the connection isn't actually
-      # going through Tor's external IP address. As there isn't a known
-      # method for checking if it is, we're checking the type instead.
-      #
-      # This isn't entirely correct. It might be a better idea to check if
-      # the source and destination addresses are both private, but that might
-      # not be perfectly reliable either.
+      # Show our external address if it's going through tor.
 
-      is_expansion_type = my_type not in (Category.SOCKS, Category.HIDDEN, Category.CONTROL)
-
-      if is_expansion_type:
+      if my_type not in (Category.SOCKS, Category.HIDDEN, Category.CONTROL):
         src_address = my_external_address + local_port
       else:
         src_address = self.connection.local_address + local_port
@@ -293,31 +283,6 @@ class ConnectionLine(object):
 
       used_space += len(src) + len(dst)  # base data requires 47 characters
 
-      # Showing the fingerprint (which has the width of 42) has priority over
-      # an expanded address field. Hence check if we either have space for
-      # both or wouldn't be showing the fingerprint regardless.
-
-      is_expanded_address_visible = width > used_space + 28
-
-      if is_expanded_address_visible:
-        is_expanded_address_visible = width < used_space + 42 or width > used_space + 70
-
-      if address_differ and is_expansion_type and is_expanded_address_visible and self.include_expanded_addresses:
-        # include the internal address in the src (extra 28 characters)
-
-        internal_address = self.connection.local_address + local_port
-
-        # If this is an inbound connection then reverse ordering so it's:
-        # <foreign> --> <external> --> <internal>
-        # when the src and dst are swapped later
-
-        if my_type == Category.INBOUND:
-          src = '%-21s  -->  %s' % (src, internal_address)
-        else:
-          src = '%-21s  -->  %s' % (internal_address, src)
-
-        used_space += 28
-
       etc = self.get_etc_content(width - used_space, listing_type)
       used_space += len(etc)
     elif listing_type == nyx.connection_panel.Listing.FINGERPRINT:





More information about the tor-commits mailing list