[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [arm/master] Dropping ipToInt() helper
commit 853bf8ba88feb863e2949ce1a91bbd19e0815b70
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date: Sat Sep 21 18:04:10 2013 -0700
Dropping ipToInt() helper
The connection util's ipToInt() helper was only used in a single spot. This
method strikes me as being too specialized to fit in stem so simply moving it
to where it's used.
---
arm/connections/connEntry.py | 11 +++++++++--
arm/util/connections.py | 16 ----------------
2 files changed, 9 insertions(+), 18 deletions(-)
diff --git a/arm/connections/connEntry.py b/arm/connections/connEntry.py
index e052a59..681f5ec 100644
--- a/arm/connections/connEntry.py
+++ b/arm/connections/connEntry.py
@@ -11,7 +11,7 @@ from arm.connections import entries
from stem.util import conf, connection, enum, str_tools
-from arm.util.connections import ipToInt, getPortUsage
+from arm.util.connections import getPortUsage
# Connection Categories:
# Inbound Relay connection, coming to us.
@@ -253,7 +253,14 @@ class ConnectionLine(entries.ConnectionPanelLine):
self.includeExpandedIpAddr = includeExpandedIpAddr
# cached immutable values used for sorting
- self.sortIpAddr = ipToInt(self.foreign.getIpAddr())
+
+ ip_value = 0
+
+ for comp in self.foreign.getIpAddr().split("."):
+ ip_value *= 255
+ ip_value += int(comp)
+
+ self.sortIpAddr = ip_value
self.sortPort = int(self.foreign.getPort())
def getListingEntry(self, width, currentTime, listingType):
diff --git a/arm/util/connections.py b/arm/util/connections.py
index 1c18233..bdb3c3f 100644
--- a/arm/util/connections.py
+++ b/arm/util/connections.py
@@ -107,22 +107,6 @@ CONFIG = conf.config_dict("arm", {
PORT_USAGE = {}
-def ipToInt(ipAddr):
- """
- Provides an integer representation of the ip address, suitable for sorting.
-
- Arguments:
- ipAddr - ip address to be converted
- """
-
- total = 0
-
- for comp in ipAddr.split("."):
- total *= 255
- total += int(comp)
-
- return total
-
def getPortUsage(port):
"""
Provides the common use of a given port. If no useage is known then this
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits