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

[tor-commits] [arm/master] Populate connection lines with IP addresses.



commit de206a1af1d8e37b3b59a077084a146f1d9ef1d0
Author: Kamran Riaz Khan <krkhan@xxxxxxxxxxxxxx>
Date:   Sun Jul 10 19:24:41 2011 +0500

    Populate connection lines with IP addresses.
---
 src/gui/connections/circEntry.py |    4 +-
 src/gui/connections/connEntry.py |   46 +++++++++++++++++++++++++++++++++-----
 src/gui/connections/connPanel.py |    2 +-
 3 files changed, 43 insertions(+), 9 deletions(-)

diff --git a/src/gui/connections/circEntry.py b/src/gui/connections/circEntry.py
index 036fbab..a7ddc13 100644
--- a/src/gui/connections/circEntry.py
+++ b/src/gui/connections/circEntry.py
@@ -16,7 +16,7 @@ class CircHeaderLine(circEntry.CircHeaderLine):
   def convertToGui(self, instance):
     instance.__class__ = self
 
-  def getListingRow(self):
+  def getListingRow(self, listingType):
     local = "%s:%s" % (self.local.ipAddr, self.local.port)
     foreign = "%s:%s" % (self.foreign.ipAddr, self.foreign.port)
     timeLabel = "%d s" % (time.time() - self.startTime)
@@ -28,7 +28,7 @@ class CircLine(circEntry.CircLine):
   def convertToGui(self, instance):
     instance.__class__ = self
 
-  def getListingRow(self):
+  def getListingRow(self, listingType):
     local = "%s:%s" % (self.local.ipAddr, self.local.port)
     foreign = "%s:%s" % (self.foreign.ipAddr, self.foreign.port)
     timeLabel = "%d s" % (time.time() - self.startTime)
diff --git a/src/gui/connections/connEntry.py b/src/gui/connections/connEntry.py
index 5888532..1acef49 100644
--- a/src/gui/connections/connEntry.py
+++ b/src/gui/connections/connEntry.py
@@ -5,7 +5,9 @@ Connection panel entries related to actual connections to or from the system
 
 import time
 
-from cli.connections import connEntry
+from cli.connections import connEntry, entries
+from cli.connections.connEntry import CONFIG, Category
+from util import uiTools, torTools
 
 class ConnectionEntry(connEntry.ConnectionEntry):
   @classmethod
@@ -17,10 +19,42 @@ class ConnectionLine(connEntry.ConnectionLine):
   def convertToGui(self, instance):
     instance.__class__ = self
 
-  def getListingRow(self):
-    local = "%s:%s" % (self.local.ipAddr, self.local.port)
-    foreign = "%s:%s" % (self.foreign.ipAddr, self.foreign.port)
-    timeLabel = "%d s" % (time.time() - self.startTime)
+  def getListingRow(self, listingType):
+    conn = torTools.getConn()
+    myType = self.getType()
+    dstAddress = self.getDestinationLabel(26, includeLocale = True)
+    localPort = ":%s" % self.local.getPort() if self.includePort else ""
 
-    return (local, foreign, timeLabel, self.baseType, 'red')
+    src, dst, etc = "", "", ""
+
+    if listingType == entries.ListingType.IP_ADDRESS:
+      myExternalIpAddr = conn.getInfo("address", self.local.getIpAddr())
+      addrDiffer = myExternalIpAddr != self.local.getIpAddr()
+
+      isExpansionType = not myType in (Category.SOCKS, Category.HIDDEN, Category.CONTROL)
+
+      if isExpansionType: srcAddress = myExternalIpAddr + localPort
+      else: srcAddress = self.local.getIpAddr() + localPort
+
+      if myType in (Category.SOCKS, Category.CONTROL):
+        src = dstAddress
+        dst = srcAddress
+      else:
+        src = srcAddress
+        dst = dstAddress
+
+      if addrDiffer and isExpansionType and self.includeExpandedIpAddr and CONFIG["features.connection.showColumn.expandedIp"]:
+        internalAddress = self.local.getIpAddr() + localPort
+
+        if myType == Category.INBOUND: (src, dst) =  (src, internalAddress)
+        else: (src, dst) =  (internalAddress, src)
+
+      etc = self.getEtcContent(100, listingType)
+    else:
+      src = "%s:%s" % (self.local.ipAddr, self.local.port)
+      dst = "%s:%s" % (self.foreign.ipAddr, self.foreign.port)
+
+    timeLabel = uiTools.getTimeLabel(time.time() - self.startTime)
+
+    return (src, dst, timeLabel, self.getType(), 'red')
 
diff --git a/src/gui/connections/connPanel.py b/src/gui/connections/connPanel.py
index 3c570c3..3b980e1 100644
--- a/src/gui/connections/connPanel.py
+++ b/src/gui/connections/connPanel.py
@@ -90,7 +90,7 @@ class ConnectionPanel(CliConnectionPanel):
       if isinstance(line, connEntry.ConnectionLine) and line.isUnresolvedApp():
         self._resolveApps()
 
-      row = line.getListingRow()
+      row = line.getListingRow(self._listingType)
 
       if isinstance(line, circEntry.CircHeaderLine):
         currentiter = treestore.append(None, row)



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