From 5484ec923dc7c2b2dad5d2af218b113c64681d94 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Fri, 16 Nov 2007 19:59:36 +0000 Subject: [PATCH] - Improved proxy support in search engine --- src/GUI.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/GUI.cpp b/src/GUI.cpp index 753f419cd..0867deae5 100644 --- a/src/GUI.cpp +++ b/src/GUI.cpp @@ -45,6 +45,7 @@ #include "options_imp.h" #include "previewSelect.h" #include "allocationDlg.h" +#include "stdlib.h" using namespace libtorrent; @@ -851,12 +852,21 @@ void GUI::configureSession(bool deleteOptions) { // * Proxy settings proxy_settings proxySettings; if(options->isProxyEnabled()) { + proxySettings.hostname = options->getProxyIp().toStdString(); + proxySettings.port = options->getProxyPort(); + if(options->isProxyAuthEnabled()) { + proxySettings.username = options->getProxyUsername().toStdString(); + proxySettings.password = options->getProxyPassword().toStdString(); + } + QString proxy_str; switch(options->getProxyType()) { case HTTP: proxySettings.type = proxy_settings::http; + proxy_str = misc::toQString("http://")+options->getProxyIp()+":"+misc::toQString(proxySettings.port); break; case HTTP_PW: proxySettings.type = proxy_settings::http_pw; + proxy_str = misc::toQString("http://")+options->getProxyUsername()+":"+options->getProxyPassword()+"@"+options->getProxyIp()+":"+misc::toQString(proxySettings.port); break; case SOCKS5: proxySettings.type = proxy_settings::socks5; @@ -865,12 +875,12 @@ void GUI::configureSession(bool deleteOptions) { proxySettings.type = proxy_settings::socks5_pw; break; } - proxySettings.hostname = options->getProxyIp().toStdString(); - proxySettings.port = options->getProxyPort(); - if(options->isProxyAuthEnabled()) { - proxySettings.username = options->getProxyUsername().toStdString(); - proxySettings.password = options->getProxyPassword().toStdString(); + if(!proxy_str.isEmpty()) { + // We need this for urllib in search engine plugins + setenv("http_proxy", proxy_str.toUtf8().data(), 1); } + } else { + unsetenv("http_proxy"); } BTSession->setProxySettings(proxySettings, options->useProxyForTrackers(), options->useProxyForPeers(), options->useProxyForWebseeds(), options->useProxyForDHT()); // * Session settings