[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r23758: {arm} Fetching multiline torrc options dynamically rather than hav (in arm/trunk/src: . util)
Author: atagar
Date: 2010-11-05 16:18:32 +0000 (Fri, 05 Nov 2010)
New Revision: 23758
Modified:
arm/trunk/src/settings.cfg
arm/trunk/src/util/torConfig.py
Log:
Fetching multiline torrc options dynamically rather than having them hardcoded in the config.
Modified: arm/trunk/src/settings.cfg
===================================================================
--- arm/trunk/src/settings.cfg 2010-11-05 15:43:39 UTC (rev 23757)
+++ arm/trunk/src/settings.cfg 2010-11-05 16:18:32 UTC (rev 23758)
@@ -78,47 +78,6 @@
torrc.map HiddenServiceAuthorizeClient => HiddenServiceOptions
torrc.map HiddenServiceOptions => HiddenServiceOptions
-# torrc parameters that can be defined multiple times without overwriting
-# from src/or/config.c (entries with LINELIST or LINELIST_S)
-# last updated for tor version 0.2.1.19
-torrc.multiline AlternateBridgeAuthority
-torrc.multiline AlternateDirAuthority
-torrc.multiline AlternateHSAuthority
-torrc.multiline AuthDirBadDir
-torrc.multiline AuthDirBadExit
-torrc.multiline AuthDirInvalid
-torrc.multiline AuthDirReject
-torrc.multiline Bridge
-torrc.multiline ControlListenAddress
-torrc.multiline ControlSocket
-torrc.multiline DirListenAddress
-torrc.multiline DirPolicy
-torrc.multiline DirServer
-torrc.multiline DNSListenAddress
-torrc.multiline ExitPolicy
-torrc.multiline HashedControlPassword
-torrc.multiline HiddenServiceDir
-torrc.multiline HiddenServiceOptions
-torrc.multiline HiddenServicePort
-torrc.multiline HiddenServiceVersion
-torrc.multiline HiddenServiceAuthorizeClient
-torrc.multiline HidServAuth
-torrc.multiline Log
-torrc.multiline MapAddress
-torrc.multiline NatdListenAddress
-torrc.multiline NodeFamily
-torrc.multiline ORListenAddress
-torrc.multiline ReachableAddresses
-torrc.multiline ReachableDirAddresses
-torrc.multiline ReachableORAddresses
-torrc.multiline RecommendedVersions
-torrc.multiline RecommendedClientVersions
-torrc.multiline RecommendedServerVersions
-torrc.multiline SocksListenAddress
-torrc.multiline SocksPolicy
-torrc.multiline TransListenAddress
-torrc.multiline __HashedControlSessionPassword
-
# valid torrc aliases from the _option_abbrevs struct of src/or/config.c
# These couldn't be requested via GETCONF (in 0.2.1.19), but I think this has
# been fixed. Discussion is in:
Modified: arm/trunk/src/util/torConfig.py
===================================================================
--- arm/trunk/src/util/torConfig.py 2010-11-05 15:43:39 UTC (rev 23757)
+++ arm/trunk/src/util/torConfig.py 2010-11-05 16:18:32 UTC (rev 23758)
@@ -9,7 +9,6 @@
from util import log, sysTools, torTools, uiTools
CONFIG = {"features.torrc.validate": True,
- "torrc.multiline": [],
"torrc.alias": {},
"torrc.label.size.b": [],
"torrc.label.size.kb": [],
@@ -48,9 +47,9 @@
MAN_OPT_INDENT = 7 # indentation before options in the man page
MAN_EX_INDENT = 15 # indentation used for man page examples
PERSIST_ENTRY_DIVIDER = "-" * 80 + "\n" # splits config entries when saving to a file
+MULTILINE_PARAM = None # cached multiline parameters (lazily loaded)
def loadConfig(config):
- CONFIG["torrc.multiline"] = config.get("torrc.multiline", [])
CONFIG["torrc.alias"] = config.get("torrc.alias", {})
# all the torrc.label.* values are comma separated lists
@@ -277,6 +276,29 @@
return torTools.getPathPrefix() + configLocation
+def getMultilineParameters():
+ """
+ Provides parameters that can be defined multiple times in the torrc without
+ overwriting the value.
+ """
+
+ # fetches config options with the LINELIST (aka 'LineList'), LINELIST_S (aka
+ # 'Dependent'), and LINELIST_V (aka 'Virtual') types
+ global MULTILINE_PARAM
+ if MULTILINE_PARAM == None:
+ conn = torTools.getConn()
+ configOptionQuery = conn.getInfo("config/names", "").strip().split("\n")
+
+ multilineEntries = []
+ for line in configOptionQuery:
+ confOption, confType = line.strip().split(" ", 1)
+ if confType in ("LineList", "Dependant", "Virtual"):
+ multilineEntries.append(confOption)
+
+ MULTILINE_PARAM = multilineEntries
+
+ return tuple(MULTILINE_PARAM)
+
def validate(contents = None):
"""
Performs validation on the given torrc contents, providing back a mapping of
@@ -298,7 +320,7 @@
else: option, value = lineText, ""
# most parameters are overwritten if defined multiple times
- if option in seenOptions and not option in CONFIG["torrc.multiline"]:
+ if option in seenOptions and not option in getMultilineParameters():
issuesFound[lineNumber] = (VAL_DUPLICATE, "")
continue
else: seenOptions.append(option)
@@ -319,7 +341,7 @@
# multiline entries can be comma separated values (for both tor and conf)
valueList = [value]
- if option in CONFIG["torrc.multiline"]:
+ if option in getMultilineParameters():
valueList = [val.strip() for val in value.split(",")]
fetchedValues, torValues = torValues, []