commit d76a91e07e59b885096e07cdbdbaca1f8349b932 Author: Damian Johnson atagar@torproject.org Date: Fri Jul 8 18:16:00 2011 -0700
Attempting to connect to the wizard port
If the initial connection fails then also tries the port the relay setup wizard uses. This is a non-standard port to avoid conflicts with TBB instances. --- src/cli/wizard.py | 4 ++-- src/settings.cfg | 1 + src/starter.py | 16 ++++++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/src/cli/wizard.py b/src/cli/wizard.py index 3ab3b9d..7e0907e 100644 --- a/src/cli/wizard.py +++ b/src/cli/wizard.py @@ -23,7 +23,7 @@ TORRC_TEMPLATE = "resources/torrcTemplate.txt" RelayType = enum.Enum("RELAY", "EXIT", "BRIDGE", "CLIENT")
# all options that can be configured -Options = enum.Enum("DIVIDER", "NICKNAME", "CONTACT", "NOTIFY", "BANDWIDTH", "LIMIT", "CLIENT", "LOWPORTS", "PORTFORWARD", "STARTUP", "NOTICE", "POLICY", "WEBSITES", "EMAIL", "IM", "MISC", "PLAINTEXT", "DISTRIBUTE", "BRIDGED", "BRIDGE1", "BRIDGE2", "BRIDGE3", "REUSE") +Options = enum.Enum("DIVIDER", "CONTROL", "NICKNAME", "CONTACT", "NOTIFY", "BANDWIDTH", "LIMIT", "CLIENT", "LOWPORTS", "PORTFORWARD", "STARTUP", "NOTICE", "POLICY", "WEBSITES", "EMAIL", "IM", "MISC", "PLAINTEXT", "DISTRIBUTE", "BRIDGED", "BRIDGE1", "BRIDGE2", "BRIDGE3", "REUSE") RelayOptions = {RelayType.RELAY: (Options.NICKNAME, Options.CONTACT, Options.NOTIFY, @@ -286,7 +286,7 @@ def showWizard():
try: os.system("tor --quiet -f %s&" % torrcLocation) - torctlConn, authType, authValue = TorCtl.preauth_connect(controlPort = 9052) + torctlConn, authType, authValue = TorCtl.preauth_connect(controlPort = int(CONFIG["wizard.default"][Options.CONTROL]))
if authType == TorCtl.AUTH_TYPE.COOKIE: torctlConn.authenticate(authValue) diff --git a/src/settings.cfg b/src/settings.cfg index 162327b..f15aa49 100644 --- a/src/settings.cfg +++ b/src/settings.cfg @@ -371,6 +371,7 @@ wizard.suboptions Bridge1 wizard.suboptions Bridge2 wizard.suboptions Bridge3
+wizard.default Control => 9052 wizard.default Notify => true wizard.default Bandwidth => 5 MB/s wizard.default Startup => true diff --git a/src/starter.py b/src/starter.py index 234bf16..58bc6b1 100644 --- a/src/starter.py +++ b/src/starter.py @@ -39,6 +39,7 @@ CONFIG = {"startup.controlPassword": None, "startup.blindModeEnabled": False, "startup.events": "N3", "startup.dataDirectory": "~/.arm", + "wizard.default": {}, "features.allowDetachedStartup": False, "features.config.descriptions.enabled": True, "features.config.descriptions.persist": True, @@ -211,6 +212,21 @@ def _torCtlConnect(controlAddr="127.0.0.1", controlPort=9051, passphrase=None, i except Exception, exc: if conn: conn.close()
+ # attempts to connect with the default wizard address too + wizardPort = CONFIG["wizard.default"].get("Control") + + if wizardPort and wizardPort.isdigit(): + wizardPort = int(wizardPort) + + # Attempt to connect to the wizard port. If the connection fails then + # don't print anything and continue with the error case for the initial + # connection failure. Otherwise, return the connection result. + + if controlPort != wizardPort: + connResult = _torCtlConnect(controlAddr, wizardPort) + if connResult != None: return connResult + else: return None # wizard connection attempt, don't print anything + if passphrase and str(exc) == "Unable to authenticate: password incorrect": # provide a warning that the provided password didn't work, then try # again prompting for the user to enter it