[tor-commits] [vidalia/master] Provide the socks port to the browser
chiiph at torproject.org
chiiph at torproject.org
Sat Aug 13 03:11:27 UTC 2011
commit b46dfc3a3ebbf38f52010db12b0a1781d392074e
Author: Tomas Touceda <chiiph at torproject.org>
Date: Wed Jul 27 11:54:09 2011 -0300
Provide the socks port to the browser
---
src/vidalia/MainWindow.cpp | 35 ++++++++++++++++++++++++++++-------
src/vidalia/MainWindow.h | 3 +++
2 files changed, 31 insertions(+), 7 deletions(-)
diff --git a/src/vidalia/MainWindow.cpp b/src/vidalia/MainWindow.cpp
index 7ef08c8..9f64163 100644
--- a/src/vidalia/MainWindow.cpp
+++ b/src/vidalia/MainWindow.cpp
@@ -595,12 +595,7 @@ MainWindow::launchBrowserFromDirectory()
QString browserDirectory = settings.getBrowserDirectory();
QString browserDirectoryFilename = settings.getBrowserExecutable();
- /* Set TZ=UTC (to stop leaking timezone information) and
- * MOZ_NO_REMOTE=1 (to allow multiple instances of Firefox */
- QStringList env = QProcess::systemEnvironment();
- env << "TZ=UTC";
- env << "MOZ_NO_REMOTE=1";
- _browserProcess->setEnvironment(env);
+ _browserProcess->setEnvironment(updateBrowserEnv());
/* The browser is in <browserDirectory>/App/Firefox/<browserDirectoryFilename> */
QString browserExecutable =
@@ -648,7 +643,7 @@ MainWindow::startSubprocesses()
launchBrowserFromDirectory();
} else if (!(subprocess = settings.getBrowserExecutable()).isEmpty()) {
/* BrowserDirectory is not set, but BrowserExecutable is; use this */
- _browserProcess->setEnvironment(QProcess::systemEnvironment() << "TZ=UTC");
+ _browserProcess->setEnvironment(updateBrowserEnv());
_browserProcess->start(subprocess, QStringList());
}
@@ -2013,3 +2008,29 @@ MainWindow::installUpdatesFailed(const QString &errmsg)
#endif
+QStringList
+MainWindow::updateBrowserEnv() {
+ TorSettings settings;
+ QStringList env = QProcess::systemEnvironment();
+ env << "TZ=UTC";
+ env << "MOZ_NO_REMOTE=1";
+
+ if(settings.autoControlPort()) {
+ QString errmsg, socks;
+ if(!(_torControl->getInfo("net/listeners/socks", socks, &errmsg))) {
+ vInfo(errmsg);
+ return env;
+ }
+
+ QStringList addrPort = socks.split(":");
+ if(addrPort.size() != 2) return env;
+
+ QHostAddress addr(addrPort.at(0));
+ quint16 port = addrPort.at(1).toInt();
+
+ env << QString("TOR_SOCKS_HOST=%1").arg(addr.toString());
+ env << QString("TOR_SOCKS_PORT=%1").arg(port);
+ }
+
+ return env;
+}
diff --git a/src/vidalia/MainWindow.h b/src/vidalia/MainWindow.h
index 6bdfec0..1412ec5 100644
--- a/src/vidalia/MainWindow.h
+++ b/src/vidalia/MainWindow.h
@@ -225,6 +225,9 @@ private:
/** Sets the progress bar completion value to <b>progressValue</b> and sets
* the status text to <b>description</b>. */
void setStartupProgress(int percentComplete, const QString &description);
+ /** Adds the needed variables to the environment that the browser will
+ * need */
+ QStringList updateBrowserEnv();
/** The current status of Tor. */
TorStatus _status;
More information about the tor-commits
mailing list