From 2196fcc911b111ee69c982d424b8918819d6704f Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Sun, 13 May 2007 20:02:30 +0000 Subject: [PATCH] - Supports SOCKS5 proxies as well as HTTP ones - Allow to use Proxy for Trackers / Peers / Web seeds / DHT connections - Redesigned Proxy options a little (for new features) --- Changelog | 11 +++- src/GUI.cpp | 17 ++++-- src/bittorrent.cpp | 14 +++-- src/bittorrent.h | 2 +- src/options.ui | 123 +++++++++++++++++++++++++++++++++++++++++++- src/options_imp.cpp | 52 +++++++++++++++++++ src/options_imp.h | 10 ++++ 7 files changed, 219 insertions(+), 10 deletions(-) diff --git a/Changelog b/Changelog index 5d45b656b..5a181750e 100644 --- a/Changelog +++ b/Changelog @@ -12,13 +12,22 @@ - FEATURE: Improved a lot the torrent creation module - FEATURE: Allow to set upload/download limit per torrent (right click) - FEATURE: Ask for exit confirmation only if download list is not empty - - FEATURE: Proxy is now used for tracker / web seeds / peers connections + - FEATURE: Allow to use a proxy for trackers / web seeds / peers / DHT connections + - FEATURE: Supports SOCKS5 proxies as well as HTTP ones - FEATURE: Better systems integration (buttons, dialogs...) - FEATURE: Fileted files are not allocated on the hard-drive anymore (if FS is compatible) - COSMETIC: Redesigned torrent properties a little - COSMETIC: Redesigned options a little - COSMETIC: Display more logs messages concerning features +* Mon May 07 2007 - Christophe Dumez - v0.9.3 + - BUGFIX: Fixed pause toggle on double-click in download list + - BUGFIX: The torrent size displayed now only takes unfiltered files into account + - BUGFIX: Fixed compiling errors with libtorrent svn (future v0.13 with UPnP enabled) + - BUGFIX: Remember sorted column in download list on restart + - BUGFIX: Small fix in the german translation + - BUGFIX: Some fixes in slovak translation + * Tue Apr 10 2007 - Christophe Dumez - v0.9.2 - BUGFIX: Window can now stay maximized on exit - BUGFIX: Use PKGCONFIG again for configuring libtorrent diff --git a/src/GUI.cpp b/src/GUI.cpp index 604975343..f3dec2a08 100644 --- a/src/GUI.cpp +++ b/src/GUI.cpp @@ -1219,16 +1219,27 @@ void GUI::configureSession(bool deleteOptions){ } // Apply Proxy settings if(options->isProxyEnabled()){ + switch(options->getProxyType()){ + case HTTP_PW: + proxySettings.type = proxy_settings::http_pw; + break; + case SOCKS5: + proxySettings.type = proxy_settings::socks5; + break; + case SOCKS5_PW: + proxySettings.type = proxy_settings::socks5_pw; + break; + default: + proxySettings.type = proxy_settings::http; + } proxySettings.hostname = options->getProxyIp().toStdString(); proxySettings.port = options->getProxyPort(); - proxySettings.type = proxy_settings::http; if(options->isProxyAuthEnabled()){ proxySettings.username = options->getProxyUsername().toStdString(); proxySettings.password = options->getProxyPassword().toStdString(); - proxySettings.type = proxy_settings::http_pw; } } - BTSession.setProxySettings(proxySettings); + BTSession.setProxySettings(proxySettings, options->useProxyForTrackers(), options->useProxyForPeers(), options->useProxyForWebseeds(), options->useProxyForDHT()); sessionSettings.user_agent = "qBittorrent "VERSION; BTSession.setSessionSettings(sessionSettings); // Scan dir stuff diff --git a/src/bittorrent.cpp b/src/bittorrent.cpp index b0c508800..217fcaf41 100644 --- a/src/bittorrent.cpp +++ b/src/bittorrent.cpp @@ -681,10 +681,16 @@ void bittorrent::setSessionSettings(session_settings sessionSettings){ } // Set Proxy -void bittorrent::setProxySettings(proxy_settings proxySettings){ - s->set_peer_proxy(proxySettings); - s->set_web_seed_proxy(proxySettings); - s->set_tracker_proxy(proxySettings); +void bittorrent::setProxySettings(proxy_settings proxySettings, bool trackers, bool peers, bool web_seeds, bool dht){ + if(trackers) + s->set_tracker_proxy(proxySettings); + if(peers) + s->set_peer_proxy(proxySettings); + if(web_seeds) + s->set_web_seed_proxy(proxySettings); + if(DHTEnabled && dht){ + s->set_dht_proxy(proxySettings); + } } // Read alerts sent by the bittorrent session diff --git a/src/bittorrent.h b/src/bittorrent.h index d739561e8..bd1b68ccc 100644 --- a/src/bittorrent.h +++ b/src/bittorrent.h @@ -116,7 +116,7 @@ class bittorrent : public QObject{ void setUploadRateLimit(int rate); void setGlobalRatio(float ratio); void setDHTPort(int dht_port); - void setProxySettings(proxy_settings proxySettings); + void setProxySettings(proxy_settings proxySettings, bool trackers=true, bool peers=true, bool web_seeds=true, bool dht=true); void setSessionSettings(session_settings sessionSettings); void setDefaultSavePath(const QString& savepath); #ifndef NO_UPNP diff --git a/src/options.ui b/src/options.ui index 48a8784dd..272298b45 100644 --- a/src/options.ui +++ b/src/options.ui @@ -1248,7 +1248,7 @@ - Server IP: + Server IP or url: @@ -1310,6 +1310,50 @@ + + + + 0 + + + 6 + + + + + Proxy type: + + + + + + + + HTTP + + + + + SOCKS5 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + @@ -1405,6 +1449,83 @@ + + + + + 0 + 110 + + + + Affected connections + + + + + 10 + 20 + 341 + 22 + + + + Use proxy for connections to trackers + + + true + + + + + + 10 + 40 + 341 + 22 + + + + Use proxy for connections to regular peers + + + true + + + + + + 10 + 60 + 341 + 22 + + + + Use proxy for connections to web seeds + + + true + + + + + + 10 + 80 + 341 + 22 + + + + Use proxy for DHT messages + + + true + + + + diff --git a/src/options_imp.cpp b/src/options_imp.cpp index 67feab401..1beaafe5f 100644 --- a/src/options_imp.cpp +++ b/src/options_imp.cpp @@ -190,6 +190,11 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){ connect(proxy_ip, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton())); connect(proxy_username, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton())); connect(proxy_password, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton())); + connect(comboProxyType, SIGNAL(currentIndexChanged(int)), this, SLOT(enableApplyButton())); + connect(checkProxyTrackers, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton())); + connect(checkProxyPeers, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton())); + connect(checkProxyWebseeds, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton())); + connect(checkProxyDHT, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton())); // Misc Settings connect(checkAdditionDialog, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton())); connect(txt_savePath, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton())); @@ -299,6 +304,16 @@ void options_imp::saveOptions(){ if(enabled){ settings.setValue("IP", getProxyIp()); settings.setValue("Port", getProxyPort()); + unsigned short val = getProxyType(); + if(val == HTTP || val == HTTP_PW){ + settings.setValue("ProxyType", HTTP); + }else{ + settings.setValue("ProxyType", SOCKS5); + } + settings.setValue("UseProxyForTrackers", useProxyForTrackers()); + settings.setValue("UseProxyForPeers", useProxyForPeers()); + settings.setValue("UseProxyForWebseeds", useProxyForWebseeds()); + settings.setValue("UseProxyForDHT", useProxyForDHT()); enabled = isProxyAuthEnabled(); settings.beginGroup("Authentication"); settings.setValue("Enabled", enabled); @@ -347,6 +362,38 @@ bool options_imp::isFilteringEnabled() const{ return activateFilter->isChecked(); } +unsigned short options_imp::getProxyType() const{ + if(comboProxyType->currentIndex() == HTTP){ + if(isProxyAuthEnabled()){ + return HTTP_PW; + }else{ + return HTTP; + } + }else{ + if(isProxyAuthEnabled()){ + return SOCKS5_PW; + }else{ + return SOCKS5; + } + } +} + +bool options_imp::useProxyForTrackers() const{ + return checkProxyTrackers->isChecked(); +} + +bool options_imp::useProxyForPeers() const{ + return checkProxyPeers->isChecked(); +} + +bool options_imp::useProxyForWebseeds() const{ + return checkProxyWebseeds->isChecked(); +} + +bool options_imp::useProxyForDHT() const{ + return checkProxyDHT->isChecked(); +} + QString options_imp::getStyle() const{ if(radioPlastiqueStyle->isChecked()) return "Plastique"; if(radioCleanlooksStyle->isChecked()) return "Cleanlooks"; @@ -522,6 +569,11 @@ void options_imp::loadOptions(){ groupProxy->setEnabled(true); proxy_ip->setText(strValue); proxy_port->setValue(settings.value("Port", 8080).toInt()); + comboProxyType->setCurrentIndex(settings.value("ProxyType", HTTP).toInt()); + checkProxyTrackers->setChecked(settings.value("useProxyForTrackers", true).toBool()); + checkProxyPeers->setChecked(settings.value("useProxyForPeers", true).toBool()); + checkProxyWebseeds->setChecked(settings.value("useProxyForWebseeds", true).toBool()); + checkProxyDHT->setChecked(settings.value("useProxyForDHT", true).toBool()); settings.beginGroup("Authentication"); if(settings.value("Enabled", false).toBool()){ enableProxyAuth_checkBox->setChecked(true); diff --git a/src/options_imp.h b/src/options_imp.h index 4e8968139..32d28a89f 100644 --- a/src/options_imp.h +++ b/src/options_imp.h @@ -27,6 +27,11 @@ #include #include +#define HTTP 0 +#define SOCKS5 1 +#define HTTP_PW 2 +#define SOCKS5_PW 3 + using namespace libtorrent; class options_imp : public QDialog, private Ui::Dialog{ @@ -69,6 +74,11 @@ class options_imp : public QDialog, private Ui::Dialog{ unsigned short getProxyPort() const; QString getProxyUsername() const; QString getProxyPassword() const; + unsigned short getProxyType() const; + bool useProxyForTrackers() const; + bool useProxyForPeers() const; + bool useProxyForWebseeds() const; + bool useProxyForDHT() const; // Language Settings QString getLocale() const; // Misc Settings