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

[tor-commits] [nyx/master] Drop everything related to connection hostnames



commit 44237aca4c6173637e7e70d6e971fd0dce799c07
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Tue Jul 7 09:26:17 2015 -0700

    Drop everything related to connection hostnames
    
    This has been dead code for years. Once upon a time arm resolved which is neat!
    But this involved active queries, which leaks a relay's circuits to their dns
    resolver.
    
    We can fix this by querying all relays (rather than just ours), but likely
    overly wasteful. Needs more investigation. Regardless, it's been dead code for
    quite some time now so about time we drop it. We can re-introduce something
    when we have hostname resolution once again.
---
 nyx/connections/circ_entry.py |   11 +----
 nyx/connections/conn_entry.py |   98 +++--------------------------------------
 nyx/connections/conn_panel.py |    6 +--
 nyx/connections/entries.py    |    7 +--
 nyx/menu/actions.py           |    1 -
 nyx/resources/nyx.1           |    2 +-
 6 files changed, 11 insertions(+), 114 deletions(-)

diff --git a/nyx/connections/circ_entry.py b/nyx/connections/circ_entry.py
index b3dc113..63108ca 100644
--- a/nyx/connections/circ_entry.py
+++ b/nyx/connections/circ_entry.py
@@ -101,11 +101,11 @@ class CircHeaderLine(conn_entry.ConnectionLine):
   def get_type(self):
     return conn_entry.Category.CIRCUIT
 
-  def get_destination_label(self, max_length, include_locale=False, include_hostname=False):
+  def get_destination_label(self, max_length, include_locale = False):
     if not self.is_built:
       return 'Building...'
 
-    return conn_entry.ConnectionLine.get_destination_label(self, max_length, include_locale, include_hostname)
+    return conn_entry.ConnectionLine.get_destination_label(self, max_length, include_locale)
 
   def get_etc_content(self, width, listing_type):
     """
@@ -187,7 +187,6 @@ class CircLine(conn_entry.ConnectionLine):
     dst, etc = '', ''
 
     if listing_type == entries.ListingType.IP_ADDRESS:
-      # TODO: include hostname when that's available
       # dst width is derived as:
       # src (21) + dst (26) + divider (7) + right gap (2) - bracket (3) = 53 char
 
@@ -198,12 +197,6 @@ class CircLine(conn_entry.ConnectionLine):
       dst = '%s%-25s   ' % (dst[:25], str_tools.crop(self.foreign.get_nickname(), 25, 0))
 
       etc = self.get_etc_content(width - baseline_space - len(dst), listing_type)
-    elif listing_type == entries.ListingType.HOSTNAME:
-      # min space for the hostname is 40 characters
-
-      etc = self.get_etc_content(width - baseline_space - 40, listing_type)
-      dst_layout = '%%-%is' % (width - baseline_space - len(etc))
-      dst = dst_layout % self.foreign.get_hostname(self.foreign.get_address())
     elif listing_type == entries.ListingType.FINGERPRINT:
       # dst width is derived as:
       # src (9) + dst (40) + divider (7) + right gap (2) - bracket (3) = 55 char
diff --git a/nyx/connections/conn_entry.py b/nyx/connections/conn_entry.py
index 562a4b4..61f2508 100644
--- a/nyx/connections/conn_entry.py
+++ b/nyx/connections/conn_entry.py
@@ -105,28 +105,6 @@ class Endpoint:
 
     return self.port
 
-  def get_hostname(self, default = None):
-    """
-    Provides the hostname associated with the relay's address. This is a
-    non-blocking call and returns None if the address either can't be resolved
-    or hasn't been resolved yet.
-
-    Arguments:
-      default - return value if no hostname is available
-    """
-
-    # TODO: skipping all hostname resolution to be safe for now
-    # try:
-    #   myHostname = hostnames.resolve(self.address)
-    # except:
-    #   # either a ValueError or IOError depending on the source of the lookup failure
-    #   myHostname = None
-    #
-    # if not myHostname: return default
-    # else: return myHostname
-
-    return default
-
   def get_locale(self, default=None):
     """
     Provides the two letter country code for the IP address' locale.
@@ -204,11 +182,6 @@ class ConnectionEntry(entries.ConnectionPanelEntry):
       return connection_line.sort_address
     elif attr == entries.SortAttr.PORT:
       return connection_line.sort_port
-    elif attr == entries.SortAttr.HOSTNAME:
-      if connection_line.is_private():
-        return ''
-
-      return connection_line.foreign.get_hostname('')
     elif attr == entries.SortAttr.FINGERPRINT:
       return connection_line.foreign.get_fingerprint()
     elif attr == entries.SortAttr.NICKNAME:
@@ -320,11 +293,6 @@ class ConnectionLine(entries.ConnectionPanelLine):
       dst - <destination addr:port>
       etc - <fingerprint> <nickname>
 
-    ListingType.HOSTNAME:
-      src - localhost:<port>
-      dst - <destination hostname:port>
-      etc - <destination addr:port> <fingerprint> <nickname>
-
     ListingType.FINGERPRINT:
       src - localhost
       dst - <destination fingerprint>
@@ -553,23 +521,6 @@ class ConnectionLine(entries.ConnectionPanelLine):
         nickname_label = str_tools.crop(self.foreign.get_nickname(), nickname_space, 0)
         etc += ('%%-%is  ' % nickname_space) % nickname_label
         used_space += nickname_space + 2
-    elif listing_type == entries.ListingType.HOSTNAME:
-      if width > used_space + 28 and CONFIG['features.connection.showColumn.destination']:
-        # show destination ip/port/locale (column width: 28 characters)
-        etc += '%-26s  ' % destination_address
-        used_space += 28
-
-      if width > used_space + 42 and CONFIG['features.connection.showColumn.fingerprint']:
-        # show fingerprint (column width: 42 characters)
-        etc += '%-40s  ' % self.foreign.get_fingerprint()
-        used_space += 42
-
-      if width > used_space + 17 and CONFIG['features.connection.showColumn.nickname']:
-        # show nickname (column width: min 17 characters, uses half of the remainder)
-        nickname_space = 15 + (width - (used_space + 17)) / 2
-        nickname_label = str_tools.crop(self.foreign.get_nickname(), nickname_space, 0)
-        etc += ('%%-%is  ' % nickname_space) % nickname_label
-        used_space += (nickname_space + 2)
     elif listing_type == entries.ListingType.FINGERPRINT:
       if width > used_space + 17:
         # show nickname (column width: min 17 characters, consumes any remaining space)
@@ -650,9 +601,9 @@ class ConnectionLine(entries.ConnectionPanelLine):
 
       if my_type in (Category.SOCKS, Category.CONTROL):
         # Like inbound connections these need their source and destination to
-        # be swapped. However, this only applies when listing by IP or hostname
-        # (their fingerprint and nickname are both for us). Reversing the
-        # fields here to keep the same column alignments.
+        # be swapped. However, this only applies when listing by IP (their
+        # fingerprint and nickname are both for us). Reversing the fields here
+        # to keep the same column alignments.
 
         src = '%-21s' % destination_address
         dst = '%-26s' % src_address
@@ -689,31 +640,6 @@ class ConnectionLine(entries.ConnectionPanelLine):
 
       etc = self.get_etc_content(width - used_space, listing_type)
       used_space += len(etc)
-    elif listing_type == entries.ListingType.HOSTNAME:
-      # 15 characters for source, and a min of 40 reserved for the destination
-      # TODO: when actually functional the src and dst need to be swapped for
-      # SOCKS and CONTROL connections
-
-      src = 'localhost%-6s' % local_port
-      used_space += len(src)
-      min_hostname_space = 40
-
-      etc = self.get_etc_content(width - used_space - min_hostname_space, listing_type)
-      used_space += len(etc)
-
-      hostname_space = width - used_space
-      used_space = width  # prevents padding at the end
-
-      if self.is_private():
-        dst = ('%%-%is' % hostname_space) % '<scrubbed>'
-      else:
-        hostname = self.foreign.get_hostname(self.foreign.get_address())
-        port_label = ':%-5s' % self.foreign.get_port() if self.include_port else ''
-
-        # truncates long hostnames and sets dst to <hostname>:<port>
-
-        hostname = str_tools.crop(hostname, hostname_space, 0)
-        dst = ('%%-%is' % hostname_space) % (hostname + port_label)
     elif listing_type == entries.ListingType.FINGERPRINT:
       src = 'localhost'
 
@@ -894,7 +820,7 @@ class ConnectionLine(entries.ConnectionPanelLine):
 
     return lines
 
-  def get_destination_label(self, max_length, include_locale = False, include_hostname = False):
+  def get_destination_label(self, max_length, include_locale = False):
     """
     Provides a short description of the destination. This is made up of two
     components, the base <ip addr>:<port> and an extra piece of information in
@@ -902,14 +828,12 @@ class ConnectionLine(entries.ConnectionPanelLine):
 
     Extra information is...
     - the port's purpose for exit connections
-    - the locale and/or hostname if set to do so, the address isn't private,
-      and isn't on the local network
+    - the locale, the address isn't private and isn't on the local network
     - nothing otherwise
 
     Arguments:
       max_length       - maximum length of the string returned
       include_locale   - possibly includes the locale
-      include_hostname - possibly includes the hostname
     """
 
     # the port and port derived data can be hidden by config or without include_port
@@ -952,18 +876,6 @@ class ConnectionLine(entries.ConnectionPanelLine):
           extra_info.append(foreign_locale)
           space_available -= len(foreign_locale) + 2
 
-        if include_hostname:
-          destination_hostname = self.foreign.get_hostname()
-
-          if destination_hostname:
-            # determines the full space available, taking into account the ", "
-            # dividers if there's multiple pieces of extra data
-
-            max_hostname_space = space_available - 2 * len(extra_info)
-            destination_hostname = str_tools.crop(destination_hostname, max_hostname_space)
-            extra_info.append(destination_hostname)
-            space_available -= len(destination_hostname)
-
         if extra_info:
           destination_address += ' (%s)' % ', '.join(extra_info)
 
diff --git a/nyx/connections/conn_panel.py b/nyx/connections/conn_panel.py
index f74c245..2be5f8b 100644
--- a/nyx/connections/conn_panel.py
+++ b/nyx/connections/conn_panel.py
@@ -22,7 +22,7 @@ DETAILS_HEIGHT = 7
 
 # listing types
 
-Listing = enum.Enum(('IP_ADDRESS', 'IP Address'), 'HOSTNAME', 'FINGERPRINT', 'NICKNAME')
+Listing = enum.Enum(('IP_ADDRESS', 'IP Address'), 'FINGERPRINT', 'NICKNAME')
 
 EXIT_USAGE_WIDTH = 15
 UPDATE_RATE = 5  # rate in seconds at which we refresh
@@ -257,10 +257,6 @@ class ConnectionPanel(panel.Panel, threading.Thread):
         title = 'List By:'
         options = list(entries.ListingType)
 
-        # dropping the HOSTNAME listing type until we support displaying that content
-
-        options.remove(nyx.connections.entries.ListingType.HOSTNAME)
-
         old_selection = options.index(self.get_listing_type())
         selection = nyx.popups.show_menu(title, options, old_selection)
 
diff --git a/nyx/connections/entries.py b/nyx/connections/entries.py
index d034aa2..68c8cb8 100644
--- a/nyx/connections/entries.py
+++ b/nyx/connections/entries.py
@@ -8,9 +8,9 @@ from stem.util import enum
 
 # attributes we can list entries by
 
-ListingType = enum.Enum(('IP_ADDRESS', 'IP Address'), 'HOSTNAME', 'FINGERPRINT', 'NICKNAME')
+ListingType = enum.Enum(('IP_ADDRESS', 'IP Address'), 'FINGERPRINT', 'NICKNAME')
 
-SortAttr = enum.Enum('CATEGORY', 'UPTIME', 'LISTING', 'IP_ADDRESS', 'PORT', 'HOSTNAME', 'FINGERPRINT', 'NICKNAME', 'COUNTRY')
+SortAttr = enum.Enum('CATEGORY', 'UPTIME', 'LISTING', 'IP_ADDRESS', 'PORT', 'FINGERPRINT', 'NICKNAME', 'COUNTRY')
 
 SORT_COLORS = {
   SortAttr.CATEGORY: 'red',
@@ -18,7 +18,6 @@ SORT_COLORS = {
   SortAttr.LISTING: 'green',
   SortAttr.IP_ADDRESS: 'blue',
   SortAttr.PORT: 'blue',
-  SortAttr.HOSTNAME: 'magenta',
   SortAttr.FINGERPRINT: 'cyan',
   SortAttr.NICKNAME: 'cyan',
   SortAttr.COUNTRY: 'blue',
@@ -88,8 +87,6 @@ class ConnectionPanelEntry:
         sort_value = self.get_sort_value(SortAttr.IP_ADDRESS, listing_type) * PORT_COUNT
         sort_value += self.get_sort_value(SortAttr.PORT, listing_type)
         return sort_value
-      elif listing_type == ListingType.HOSTNAME:
-        return self.get_sort_value(SortAttr.HOSTNAME, listing_type)
       elif listing_type == ListingType.FINGERPRINT:
         return self.get_sort_value(SortAttr.FINGERPRINT, listing_type)
       elif listing_type == ListingType.NICKNAME:
diff --git a/nyx/menu/actions.py b/nyx/menu/actions.py
index 25b7c14..42d4bb3 100644
--- a/nyx/menu/actions.py
+++ b/nyx/menu/actions.py
@@ -249,7 +249,6 @@ def make_connections_menu(conn_panel):
   listing_group = nyx.menu.item.SelectionGroup(conn_panel.set_listing_type, conn_panel.get_listing_type())
 
   listing_options = list(nyx.connections.entries.ListingType)
-  listing_options.remove(nyx.connections.entries.ListingType.HOSTNAME)
 
   for option in listing_options:
     connections_menu.add(nyx.menu.item.SelectionMenuItem(option, listing_group, option))
diff --git a/nyx/resources/nyx.1 b/nyx/resources/nyx.1
index d82528a..a2a8d40 100644
--- a/nyx/resources/nyx.1
+++ b/nyx/resources/nyx.1
@@ -13,7 +13,7 @@ providing real time statistics for:
   * bandwidth, cpu, and memory usage
   * relay's current configuration
   * logged events
-  * connection details (ip, hostname, fingerprint, and consensus data)
+  * connection details (ip, fingerprint, and consensus data)
   * etc
 
 Defaults and interface properties are configurable via a user provided



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