[tor-commits] r24548: {arm} Using both the IP and port as sort attibutes when sorting by (arm/trunk/src/interface/connections)

Damian Johnson atagar1 at gmail.com
Sun Apr 3 06:36:27 UTC 2011


Author: atagar
Date: 2011-04-03 06:36:26 +0000 (Sun, 03 Apr 2011)
New Revision: 24548

Modified:
   arm/trunk/src/interface/connections/entries.py
Log:
Using both the IP and port as sort attibutes when sorting by listed IP entries.



Modified: arm/trunk/src/interface/connections/entries.py
===================================================================
--- arm/trunk/src/interface/connections/entries.py	2011-04-03 06:28:09 UTC (rev 24547)
+++ arm/trunk/src/interface/connections/entries.py	2011-04-03 06:36:26 UTC (rev 24548)
@@ -18,6 +18,9 @@
                SortAttr.FINGERPRINT: "cyan",  SortAttr.NICKNAME: "cyan",
                SortAttr.COUNTRY: "blue"}
 
+# maximum number of ports a system can have
+PORT_COUNT = 65536
+
 class ConnectionPanelEntry:
   """
   Common parent for connection panel entries. This consists of a list of lines
@@ -73,7 +76,10 @@
     
     if attr == SortAttr.LISTING:
       if listingType == ListingType.IP_ADDRESS:
-        return self.getSortValue(SortAttr.IP_ADDRESS, listingType)
+        # uses the IP address as the primary value, and port as secondary
+        sortValue = self.getSortValue(SortAttr.IP_ADDRESS, listingType) * PORT_COUNT
+        sortValue += self.getSortValue(SortAttr.PORT, listingType)
+        return sortValue
       elif listingType == ListingType.HOSTNAME:
         return self.getSortValue(SortAttr.HOSTNAME, listingType)
       elif listingType == ListingType.FINGERPRINT:



More information about the tor-commits mailing list