commit 05681ccbd647d2e92143f19f747c39358e5c7d9a Author: Tomás Touceda chiiph@torproject.org Date: Thu Sep 1 19:24:47 2011 -0300
Add more checks for the autoconfiguration --- src/vidalia/MainWindow.cpp | 20 +++++++++++++++++--- src/vidalia/config/AdvancedPage.cpp | 15 ++++++++++++++- 2 files changed, 31 insertions(+), 4 deletions(-)
diff --git a/src/vidalia/MainWindow.cpp b/src/vidalia/MainWindow.cpp index 37eca8c..8dbf8ae 100644 --- a/src/vidalia/MainWindow.cpp +++ b/src/vidalia/MainWindow.cpp @@ -526,6 +526,15 @@ MainWindow::start()
updateTorStatus(Starting);
+ // Disable autoconfiguration if there are missing config data + if(settings.autoControlPort()) { + if(settings.getDataDirectory().isEmpty()) { + vWarn("Disabling ControlPort autoconfiguration. DataDirectory is empty!"); + settings.setAutoControlPort(false); + } + } + + /* Check if Tor is already running separately */ if(settings.getControlMethod() == ControlMethod::Port) { if(!settings.autoControlPort() && net_test_connect(settings.getControlAddress(), @@ -643,9 +652,14 @@ MainWindow::started()
if(tries >= maxtries) { vWarn("Couldn't read port.conf file"); - connectFailed(QString("Vidalia can't find out how to talk to Tor because it can't access this file: %1\n\nHere's the last error message:\n %2") - .arg(file.fileName()) - .arg(file.errorString())); + if(_torControl->isRunning()) { + connectFailed(tr("Vidalia can't find out how to talk to Tor because it can't access this file: %1\n\nHere's the last error message:\n%2") + .arg(file.fileName()) + .arg(file.errorString())); + } else { + vWarn("Tor isn't running!"); + connectFailed(tr("It seems Tor has stopped running since Vidalia started it.\n\nSee the Advanced Message Log for more information.")); + } return; }
diff --git a/src/vidalia/config/AdvancedPage.cpp b/src/vidalia/config/AdvancedPage.cpp index 12842bc..0f532e7 100644 --- a/src/vidalia/config/AdvancedPage.cpp +++ b/src/vidalia/config/AdvancedPage.cpp @@ -121,6 +121,16 @@ AdvancedPage::save(QString &errmsg) QHostAddress controlAddress(ui.lineControlAddress->text()); QString path(ui.lineSocketPath->text());
+ if(ui.chkAuto->isChecked()) { + if(ui.lineTorDataDirectory->text().isEmpty()) { + errmsg = tr("You've checked the autoconfiguration option for the ControlPort, but" + " provided no Data Directory. Please add one, or uncheck the" + " "Configure ControlPort automatically" option."); + return false; + } + _settings->setAutoControlPort(true); + } + /* Validate the control settings */ if(ui.rdoControlPort->isChecked()) { if (controlAddress.isNull()) { @@ -190,7 +200,6 @@ AdvancedPage::save(QString &errmsg) _settings->setControlPort(ui.lineControlPort->text().toUShort()); } _settings->setSocketPath(ui.lineSocketPath->text()); - _settings->setAutoControlPort(ui.chkAuto->isChecked());
_settings->setAuthenticationMethod(authMethod); _settings->setUseRandomPassword(ui.chkRandomPassword->isChecked()); @@ -233,6 +242,10 @@ AdvancedPage::load() ui.chkUseService->setChecked(s.isInstalled()); #endif #endif + if(Vidalia::torControl()->getTorVersion() < 0x2021a) { // 0x2021a == 0.2.2.26 + ui.chkAuto->setChecked(false); + ui.chkAuto->setVisible(false); + } }
/** Called when the user selects a different authentication method from the