[or-cvs] r24083: {arm} Hiding most tor config values by default (idea by arma). (in arm/trunk: . src src/interface src/util)
Damian Johnson
atagar1 at gmail.com
Sat Jan 15 20:05:23 UTC 2011
Author: atagar
Date: 2011-01-15 20:05:23 +0000 (Sat, 15 Jan 2011)
New Revision: 24083
Modified:
arm/trunk/armrc.sample
arm/trunk/src/interface/configPanel.py
arm/trunk/src/settings.cfg
arm/trunk/src/util/torConfig.py
Log:
Hiding most tor config values by default (idea by arma).
Modified: arm/trunk/armrc.sample
===================================================================
--- arm/trunk/armrc.sample 2011-01-15 17:18:19 UTC (rev 24082)
+++ arm/trunk/armrc.sample 2011-01-15 20:05:23 UTC (rev 24083)
@@ -92,7 +92,7 @@
features.config.selectionDetails.height 6
features.config.prepopulateEditValues true
features.config.state.colWidth.option 25
-features.config.state.colWidth.value 10
+features.config.state.colWidth.value 15
features.config.state.showPrivateOptions false
features.config.state.showVirtualOptions false
features.config.file.showScrollbars true
Modified: arm/trunk/src/interface/configPanel.py
===================================================================
--- arm/trunk/src/interface/configPanel.py 2011-01-15 17:18:19 UTC (rev 24082)
+++ arm/trunk/src/interface/configPanel.py 2011-01-15 20:05:23 UTC (rev 24083)
@@ -12,7 +12,7 @@
"features.config.state.showPrivateOptions": False,
"features.config.state.showVirtualOptions": False,
"features.config.state.colWidth.option": 25,
- "features.config.state.colWidth.value": 10}
+ "features.config.state.colWidth.value": 15}
# TODO: The arm use cases are incomplete since they currently can't be
# modified, have their descriptions fetched, or even get a complete listing
@@ -131,6 +131,10 @@
self.scroller = uiTools.Scroller(True)
self.valsLock = threading.RLock()
+ # shows all configuration options if true, otherwise only the ones with
+ # the 'important' flag are shown
+ self.showAll = False
+
if self.configType == TOR_STATE:
conn = torTools.getConn()
customOptions = torConfig.getCustomOptions()
@@ -150,20 +154,30 @@
summary = torConfig.getConfigSummary(confOption)
manEntry = torConfig.getConfigDescription(confOption)
self.confContents.append(ConfigEntry(confOption, confType, not confOption in customOptions, summary, manEntry))
-
- self.setSortOrder() # initial sorting of the contents
elif self.configType == ARM_STATE:
# loaded via the conf utility
armConf = conf.getConfig("arm")
for key in armConf.getKeys():
pass # TODO: implement
+
+ # mirror listing with only the important configuration options
+ self.confImportantContents = []
+ for entry in self.confContents:
+ if torConfig.isImportant(entry.get(FIELD_OPTION)):
+ self.confImportantContents.append(entry)
+
+ # if there aren't any important options then show everything
+ if not self.confImportantContents:
+ self.confImportantContents = self.confContents
+
+ self.setSortOrder() # initial sorting of the contents
def getSelection(self):
"""
Provides the currently selected entry.
"""
- return self.scroller.getCursorSelection(self.confContents)
+ return self.scroller.getCursorSelection(self._getConfigOptions())
def setSortOrder(self, ordering = None):
"""
@@ -178,6 +192,7 @@
self.valsLock.acquire()
if ordering: self.sortOrdering = ordering
self.confContents.sort(key=lambda i: (i.getAttr(self.sortOrdering)))
+ self.confImportantContents.sort(key=lambda i: (i.getAttr(self.sortOrdering)))
self.valsLock.release()
def handleKey(self, key):
@@ -188,45 +203,54 @@
if detailPanelHeight > 0 and detailPanelHeight + 2 <= pageHeight:
pageHeight -= (detailPanelHeight + 1)
- isChanged = self.scroller.handleKey(key, self.confContents, pageHeight)
+ isChanged = self.scroller.handleKey(key, self._getConfigOptions(), pageHeight)
if isChanged: self.redraw(True)
+ elif key == ord('a') or key == ord('A'):
+ self.showAll = not self.showAll
+ self.redraw(True)
self.valsLock.release()
def draw(self, subwindow, width, height):
self.valsLock.acquire()
# draws the top label
- titleLabel = "%s Configuration:" % ("Tor" if self.configType == TOR_STATE else "Arm")
+ configType = "Tor" if self.configType == TOR_STATE else "Arm"
+ hiddenMsg = "press 'a' to hide most options" if self.showAll else "press 'a' to show all options"
+
+ titleLabel = "%s Configuration (%s):" % (configType, hiddenMsg)
self.addstr(0, 0, titleLabel, curses.A_STANDOUT)
# panel with details for the current selection
detailPanelHeight = self._config["features.config.selectionDetails.height"]
+ isScrollbarVisible = False
if detailPanelHeight == 0 or detailPanelHeight + 2 >= height:
# no detail panel
detailPanelHeight = 0
- scrollLoc = self.scroller.getScrollLoc(self.confContents, height - 1)
+ scrollLoc = self.scroller.getScrollLoc(self._getConfigOptions(), height - 1)
cursorSelection = self.getSelection()
+ isScrollbarVisible = len(self._getConfigOptions()) > height - 1
else:
# Shrink detail panel if there isn't sufficient room for the whole
# thing. The extra line is for the bottom border.
detailPanelHeight = min(height - 1, detailPanelHeight + 1)
- scrollLoc = self.scroller.getScrollLoc(self.confContents, height - 1 - detailPanelHeight)
+ scrollLoc = self.scroller.getScrollLoc(self._getConfigOptions(), height - 1 - detailPanelHeight)
cursorSelection = self.getSelection()
+ isScrollbarVisible = len(self._getConfigOptions()) > height - detailPanelHeight - 1
- self._drawSelectionPanel(cursorSelection, width, detailPanelHeight, titleLabel)
+ self._drawSelectionPanel(cursorSelection, width, detailPanelHeight, titleLabel, isScrollbarVisible)
# draws left-hand scroll bar if content's longer than the height
- scrollOffset = 0
- if len(self.confContents) > height - detailPanelHeight - 1:
+ scrollOffset = 1
+ if isScrollbarVisible:
scrollOffset = 3
- self.addScrollBar(scrollLoc, scrollLoc + height - detailPanelHeight - 1, len(self.confContents), 1 + detailPanelHeight)
+ self.addScrollBar(scrollLoc, scrollLoc + height - detailPanelHeight - 1, len(self._getConfigOptions()), 1 + detailPanelHeight)
optionWidth = self._config["features.config.state.colWidth.option"]
valueWidth = self._config["features.config.state.colWidth.value"]
descriptionWidth = max(0, width - scrollOffset - optionWidth - valueWidth - 2)
- for lineNum in range(scrollLoc, len(self.confContents)):
- entry = self.confContents[lineNum]
+ for lineNum in range(scrollLoc, len(self._getConfigOptions())):
+ entry = self._getConfigOptions()[lineNum]
drawLine = lineNum + detailPanelHeight + 1 - scrollLoc
optionLabel = uiTools.cropStr(entry.get(FIELD_OPTION), optionWidth)
@@ -245,7 +269,10 @@
self.valsLock.release()
- def _drawSelectionPanel(self, cursorSelection, width, detailPanelHeight, titleLabel):
+ def _getConfigOptions(self):
+ return self.confContents if self.showAll else self.confImportantContents
+
+ def _drawSelectionPanel(self, cursorSelection, width, detailPanelHeight, titleLabel, isScrollbarVisible):
"""
Renders a panel for the selected configuration option.
"""
@@ -260,9 +287,11 @@
self.win.vline(1, width, curses.ACS_VLINE, detailPanelHeight - 1)
# border (bottom)
+ # This is a solid border unless the scrollbar is visible, in which case a
+ # 'T' pipe connects the border to the bar.
self.win.addch(detailPanelHeight, 0, curses.ACS_LLCORNER)
- if width >= 2: self.win.addch(detailPanelHeight, 1, curses.ACS_TTEE)
- if width >= 3: self.win.hline(detailPanelHeight, 2, curses.ACS_HLINE, width - 2)
+ if width >= 2: self.win.hline(detailPanelHeight, 1, curses.ACS_HLINE, width - 1)
+ if width >= 2 and isScrollbarVisible: self.win.addch(detailPanelHeight, 1, curses.ACS_TTEE)
self.win.addch(detailPanelHeight, width, curses.ACS_LRCORNER)
selectionFormat = curses.A_BOLD | uiTools.getColor(CATEGORY_COLOR[cursorSelection.get(FIELD_CATEGORY)])
Modified: arm/trunk/src/settings.cfg
===================================================================
--- arm/trunk/src/settings.cfg 2011-01-15 17:18:19 UTC (rev 24082)
+++ arm/trunk/src/settings.cfg 2011-01-15 20:05:23 UTC (rev 24083)
@@ -1,3 +1,32 @@
+# Important tor configuration options (shown by default)
+config.important BandwidthRate
+config.important BandwidthBurst
+config.important RelayBandwidthRate
+config.important RelayBandwidthBurst
+config.important ControlPort
+config.important HashedControlPassword
+config.important CookieAuthentication
+config.important DataDirectory
+config.important Log
+config.important RunAsDaemon
+config.important User
+config.important Bridge
+config.important ExcludeNodes
+config.important SocksPort
+config.important UseBridges
+config.important BridgeRelay
+config.important ContactInfo
+config.important ExitPolicy
+config.important MyFamily
+config.important Nickname
+config.important ORPort
+config.important AccountingMax
+config.important AccountingStart
+config.important DirPortFrontPage
+config.important DirPort
+config.important HiddenServiceDir
+config.important HiddenServicePort
+
# Summary descriptions for Tor configuration options
# General Config Options
config.summary.BandwidthRate Average bandwidth usage limit
@@ -177,7 +206,7 @@
config.summary.AuthDirMaxServersPerAddr limit on the number of relays accepted per ip
config.summary.AuthDirMaxServersPerAuthAddr limit on the number of relays accepted per an authority's ip
config.summary.V3AuthVotingInterval consensus voting interval
-config.summary.V3AuthVotingInterval wait time to collect votes of other authorities
+config.summary.V3AuthVoteDelay wait time to collect votes of other authorities
config.summary.V3AuthDistDelay wait time to collect the signatures of other authorities
config.summary.V3AuthNIntervalsValid number of voting intervals a consensus is valid for
config.summary.V3BandwidthsFile path to a file containing measured relay bandwidths
Modified: arm/trunk/src/util/torConfig.py
===================================================================
--- arm/trunk/src/util/torConfig.py 2011-01-15 17:18:19 UTC (rev 24082)
+++ arm/trunk/src/util/torConfig.py 2011-01-15 20:05:23 UTC (rev 24083)
@@ -8,6 +8,7 @@
from util import log, sysTools, torTools, uiTools
CONFIG = {"features.torrc.validate": True,
+ "config.important": [],
"torrc.alias": {},
"torrc.label.size.b": [],
"torrc.label.size.kb": [],
@@ -51,10 +52,13 @@
MULTILINE_PARAM = None # cached multiline parameters (lazily loaded)
def loadConfig(config):
- CONFIG["torrc.alias"] = config.get("torrc.alias", {})
+ config.update(CONFIG)
- # fetches any config.summary.* values
+ # stores lowercase entries to drop case sensitivity
+ CONFIG["config.important"] = [entry.lower() for entry in CONFIG["config.important"]]
+
for configKey in config.getKeys():
+ # fetches any config.summary.* values
if configKey.startswith("config.summary."):
CONFIG[configKey.lower()] = config.get(configKey)
@@ -286,6 +290,17 @@
return CONFIG.get("config.summary.%s" % option.lower())
+def isImportant(option):
+ """
+ Provides True if the option has the 'important' flag in the configuration,
+ False otherwise.
+
+ Arguments:
+ option - tor config option
+ """
+
+ return option.lower() in CONFIG["config.important"]
+
def getConfigDescription(option):
"""
Provides ManPageEntry instances populated with information fetched from the
More information about the tor-commits
mailing list