[tor-commits] [nyx/master] Expanded SocksPort caused a stacktrace

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


commit 22a5dc2abcac959a29a351c276f576cd027446a6
Author: Damian Johnson <atagar at torproject.org>
Date:   Sun Jul 26 12:14:31 2015 -0700

    Expanded SocksPort caused a stacktrace
    
    There might be other spots too, but when tor added additional field to the
    SocksPort torrc entry we broke due to expecting an integer.
---
 nyx/connections/conn_entry.py |   22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/nyx/connections/conn_entry.py b/nyx/connections/conn_entry.py
index 42466d9..d945182 100644
--- a/nyx/connections/conn_entry.py
+++ b/nyx/connections/conn_entry.py
@@ -11,6 +11,7 @@ import nyx.util.ui_tools
 from nyx.util import tor_controller
 from nyx.connections import entries
 
+from stem.control import Listener
 from stem.util import conf, connection, enum, str_tools
 
 # Connection Categories:
@@ -82,10 +83,10 @@ class ConnectionLine(entries.ConnectionPanelLine):
     self.application_pid = None
     self.is_application_resolving = False
 
-    my_or_port = controller.get_conf('ORPort', None)
-    my_dir_port = controller.get_conf('DirPort', None)
-    my_socks_port = controller.get_conf('SocksPort', '9050')
-    my_ctl_port = controller.get_conf('ControlPort', None)
+    socks_ports = controller.get_ports(Listener.SOCKS, [])
+    or_ports = controller.get_ports(Listener.OR, [])
+    dir_ports = controller.get_ports(Listener.DIR, [])
+    control_ports = controller.get_ports(Listener.CONTROL, [])
 
     # get all target ports in our hidden service configuation
 
@@ -94,20 +95,13 @@ class ConnectionLine(entries.ConnectionPanelLine):
     for hs_config in controller.get_hidden_service_conf({}).values():
       my_hidden_service_ports += [entry[2] for entry in hs_config['HiddenServicePort']]
 
-    # the ORListenAddress can overwrite the ORPort
-
-    listen_addr = controller.get_conf('ORListenAddress', None)
-
-    if listen_addr and ':' in listen_addr:
-      my_or_port = listen_addr[listen_addr.find(':') + 1:]
-
-    if conn.local_port in (my_or_port, my_dir_port):
+    if conn.local_port in or_ports or conn.local_port in dir_ports:
       self.base_type = Category.INBOUND
-    elif conn.local_port == my_socks_port:
+    elif conn.local_port in socks_ports:
       self.base_type = Category.SOCKS
     elif conn.remote_port in my_hidden_service_ports:
       self.base_type = Category.HIDDEN
-    elif conn.local_port == my_ctl_port:
+    elif conn.local_port in control_ports:
       self.base_type = Category.CONTROL
     else:
       self.base_type = Category.OUTBOUND





More information about the tor-commits mailing list