[tor-commits] r24293: {arm} Adding a config option for connection panel column visabilit (in arm/trunk: . src/interface src/interface/connections)
Damian Johnson
atagar1 at gmail.com
Thu Mar 3 03:37:40 UTC 2011
Author: atagar
Date: 2011-03-03 03:37:40 +0000 (Thu, 03 Mar 2011)
New Revision: 24293
Modified:
arm/trunk/armrc.sample
arm/trunk/src/interface/connections/listings.py
arm/trunk/src/interface/controller.py
Log:
Adding a config option for connection panel column visability.
Modified: arm/trunk/armrc.sample
===================================================================
--- arm/trunk/armrc.sample 2011-03-02 21:16:07 UTC (rev 24292)
+++ arm/trunk/armrc.sample 2011-03-03 03:37:40 UTC (rev 24293)
@@ -151,6 +151,16 @@
features.graph.bw.accounting.rate 10
features.graph.bw.accounting.isTimeLong false
+# Parameters for connection display
+# ---------------------------------
+# features.connection.showColumn.*
+# toggles the visability of the connection table columns
+
+features.connection.showColumn.fingerprint true
+features.connection.showColumn.nickname true
+features.connection.showColumn.destination true
+features.connection.showColumn.expanedIp true
+
# Thread pool size for hostname resolutions
# Determines the maximum number of concurrent requests. Upping this to around
# thirty or so seems to be problematic, causing intermittently seizing.
Modified: arm/trunk/src/interface/connections/listings.py
===================================================================
--- arm/trunk/src/interface/connections/listings.py 2011-03-02 21:16:07 UTC (rev 24292)
+++ arm/trunk/src/interface/connections/listings.py 2011-03-03 03:37:40 UTC (rev 24293)
@@ -7,15 +7,14 @@
from util import connections, enum, hostnames, torTools, uiTools
# Connection Categories:
-# Inbound Relay connection, coming to us.
-# Outbound Relay connection, leaving us.
-# Exit Outbound relay connection leaving the Tor network.
-# Socks Application client connection.
-# Client Circuits for our client traffic.
-# Directory Fetching tor consensus information.
-# Control Tor controller (arm, vidalia, etc).
+# Inbound Relay connection, coming to us.
+# Outbound Relay connection, leaving us.
+# Exit Outbound relay connection leaving the Tor network.
+# Client Circuits for our client traffic.
+# Application Socks connections using Tor.
+# Directory Fetching tor consensus information.
+# Control Tor controller (arm, vidalia, etc).
-# TODO: add recognizing of CLIENT connection type
DestAttr = enum.Enum("NONE", "LOCALE", "HOSTNAME")
Category = enum.Enum("INBOUND", "OUTBOUND", "EXIT", "CLIENT", "APPLICATION", "DIRECTORY", "CONTROL")
CATEGORY_COLOR = {Category.INBOUND: "green", Category.OUTBOUND: "blue",
@@ -28,6 +27,14 @@
LABEL_FORMAT = "%s --> %s %s%s"
LABEL_MIN_PADDING = 2 # min space between listing label and following data
+CONFIG = {"features.connection.showColumn.fingerprint": True,
+ "features.connection.showColumn.nickname": True,
+ "features.connection.showColumn.destination": True,
+ "features.connection.showColumn.expanedIp": True}
+
+def loadConfig(config):
+ config.update(CONFIG)
+
class Endpoint:
"""
Collection of attributes associated with a connection endpoint. This is a
@@ -348,18 +355,18 @@
usedSpace += len(src) + len(dst) # base data requires 47 characters
- if width > usedSpace + 42:
+ if width > usedSpace + 42 and CONFIG["features.connection.showColumn.fingerprint"]:
# show fingerprint (column width: 42 characters)
etc += "%-40s " % self.foreign.getFingerprint()
usedSpace += 42
- if addrDiffer and width > usedSpace + 28:
+ if addrDiffer and width > usedSpace + 28 and CONFIG["features.connection.showColumn.expanedIp"]:
# include the internal address in the src (extra 28 characters)
internalAddress = "%s:%s" % (self.local.getIpAddr(), self.local.getPort())
src = "%-21s --> %s" % (internalAddress, src)
usedSpace += 28
- if width > usedSpace + 10:
+ if width > usedSpace + 10 and CONFIG["features.connection.showColumn.nickname"]:
# show nickname (column width: remainder)
nicknameSpace = width - usedSpace
nicknameLabel = uiTools.cropStr(self.foreign.getNickname(), nicknameSpace, 0)
@@ -371,17 +378,17 @@
usedSpace += len(stc)
minHostnameSpace = 40
- if width > usedSpace + minHostnameSpace + 28:
+ if width > usedSpace + minHostnameSpace + 28 and CONFIG["features.connection.showColumn.destination"]:
# show destination ip/port/locale (column width: 28 characters)
etc += "%-26s " % dstAddress
usedSpace += 28
- if width > usedSpace + minHostnameSpace + 42:
+ if width > usedSpace + minHostnameSpace + 42 and CONFIG["features.connection.showColumn.fingerprint"]:
# show fingerprint (column width: 42 characters)
etc += "%-40s " % self.foreign.getFingerprint()
usedSpace += 42
- if width > usedSpace + minHostnameSpace + 17:
+ if width > usedSpace + minHostnameSpace + 17 and CONFIG["features.connection.showColumn.nickname"]:
# show nickname (column width: min 17 characters, uses half of the remainder)
nicknameSpace = 15 + (width - (usedSpace + minHostnameSpace + 17)) / 2
nicknameLabel = uiTools.cropStr(self.foreign.getNickname(), nicknameSpace, 0)
@@ -417,12 +424,14 @@
# if there's room then also show a column with the destination
# ip/port/locale (column width: 28 characters)
isIpLocaleIncluded = width > usedSpace + 45
+ isIpLocaleIncluded &= CONFIG["features.connection.showColumn.destination"]
if isIpLocaleIncluded: nicknameSpace -= 28
- nicknameSpace = width - usedSpace - 28 if isIpLocaleVisible else width - usedSpace
- nicknameLabel = uiTools.cropStr(self.foreign.getNickname(), nicknameSpace, 0)
- etc += ("%%-%is " % nicknameSpace) % nicknameLabel
- usedSpace += nicknameSpace + 2
+ if CONFIG["features.connection.showColumn.nickname"]:
+ nicknameSpace = width - usedSpace - 28 if isIpLocaleVisible else width - usedSpace
+ nicknameLabel = uiTools.cropStr(self.foreign.getNickname(), nicknameSpace, 0)
+ etc += ("%%-%is " % nicknameSpace) % nicknameLabel
+ usedSpace += nicknameSpace + 2
if isIpLocaleIncluded:
etc += "%-26s " % dstAddress
@@ -434,12 +443,12 @@
else: dst = self.foreign.getNickname()
minBaseSpace = 50
- if width > usedSpace + minBaseSpace + 42:
+ if width > usedSpace + minBaseSpace + 42 and CONFIG["features.connection.showColumn.fingerprint"]:
# show fingerprint (column width: 42 characters)
etc += "%-40s " % self.foreign.getFingerprint()
usedSpace += 42
- if width > usedSpace + minBaseSpace + 28:
+ if width > usedSpace + minBaseSpace + 28 and CONFIG["features.connection.showColumn.destination"]:
# show destination ip/port/locale (column width: 28 characters)
etc += "%-26s " % dstAddress
usedSpace += 28
Modified: arm/trunk/src/interface/controller.py
===================================================================
--- arm/trunk/src/interface/controller.py 2011-03-02 21:16:07 UTC (rev 24292)
+++ arm/trunk/src/interface/controller.py 2011-03-03 03:37:40 UTC (rev 24293)
@@ -25,6 +25,7 @@
import fileDescriptorPopup
import interface.connections.connPanel
+import interface.connections.listings
from util import conf, log, connections, hostnames, panel, sysTools, torConfig, torTools, uiTools
import graphing.bandwidthStats
import graphing.connStats
@@ -426,6 +427,7 @@
config = conf.getConfig("arm")
config.update(CONFIG)
graphing.graphPanel.loadConfig(config)
+ interface.connections.listings.loadConfig(config)
# adds events needed for arm functionality to the torTools REQ_EVENTS mapping
# (they're then included with any setControllerEvents call, and log a more
More information about the tor-commits
mailing list