mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-29 05:48:47 +03:00
Fix to proxy settings
Added back SOCKS5 proxy support for HTTP communications
This commit is contained in:
parent
6ae49acb69
commit
296acf820c
4 changed files with 58 additions and 24 deletions
|
@ -538,6 +538,18 @@ void Bittorrent::configureSession() {
|
|||
http_proxySettings.hostname = Preferences::getHTTPProxyIp().toStdString();
|
||||
http_proxySettings.port = Preferences::getHTTPProxyPort();
|
||||
break;
|
||||
case SOCKS5:
|
||||
http_proxySettings.type = proxy_settings::socks5;
|
||||
http_proxySettings.hostname = Preferences::getHTTPProxyIp().toStdString();
|
||||
http_proxySettings.port = Preferences::getHTTPProxyPort();
|
||||
break;
|
||||
case SOCKS5_PW:
|
||||
http_proxySettings.type = proxy_settings::socks5_pw;
|
||||
http_proxySettings.username = Preferences::getHTTPProxyUsername().toStdString();
|
||||
http_proxySettings.password = Preferences::getHTTPProxyPassword().toStdString();
|
||||
http_proxySettings.hostname = Preferences::getHTTPProxyIp().toStdString();
|
||||
http_proxySettings.port = Preferences::getHTTPProxyPort();
|
||||
break;
|
||||
default:
|
||||
http_proxySettings.type = proxy_settings::none;
|
||||
}
|
||||
|
|
|
@ -35,6 +35,8 @@
|
|||
#include <QNetworkRequest>
|
||||
#include <QNetworkProxy>
|
||||
|
||||
enum ProxyType {HTTP=1, SOCKS5=2, HTTP_PW=3, SOCKS5_PW=4, SOCKS4=5};
|
||||
|
||||
/** Download Thread **/
|
||||
|
||||
downloadThread::downloadThread(QObject* parent) : QObject(parent) {
|
||||
|
@ -105,7 +107,7 @@ void downloadThread::applyProxySettings() {
|
|||
qDebug("Using proxy: %s", (IP+QString(":")+port).toLocal8Bit().data());
|
||||
proxy.setPort(port.toUShort());
|
||||
// Default proxy type is HTTP, we must change if it is SOCKS5
|
||||
if(intValue%2==0) {
|
||||
if(intValue == SOCKS5 || intValue == SOCKS5_PW) {
|
||||
qDebug("Proxy is SOCKS5, not HTTP");
|
||||
proxy.setType(QNetworkProxy::Socks5Proxy);
|
||||
} else {
|
||||
|
|
|
@ -520,13 +520,22 @@ int options_imp::getPeerProxyType() const{
|
|||
}
|
||||
|
||||
int options_imp::getHTTPProxyType() const {
|
||||
if(comboProxyType_http->currentIndex() > 0){
|
||||
switch(comboProxyType_http->currentIndex()) {
|
||||
case 1: {
|
||||
if(isHTTPProxyAuthEnabled()){
|
||||
return HTTP_PW;
|
||||
}
|
||||
return HTTP;
|
||||
}
|
||||
return -1; // disabled
|
||||
case 2: {
|
||||
if(isHTTPProxyAuthEnabled()) {
|
||||
return SOCKS5_PW;
|
||||
}
|
||||
return SOCKS5;
|
||||
}
|
||||
default:
|
||||
return -1; // Disabled
|
||||
}
|
||||
}
|
||||
|
||||
int options_imp::getStyle() const{
|
||||
|
@ -637,17 +646,18 @@ void options_imp::loadOptions(){
|
|||
checkResolveHosts->setChecked(Preferences::resolvePeerHostNames());
|
||||
|
||||
intValue = Preferences::getPeerProxyType();
|
||||
if(intValue <= 0) {
|
||||
intValue = 0;
|
||||
} else {
|
||||
if(intValue%2 == 0) {
|
||||
intValue = 2;
|
||||
}else {
|
||||
intValue = 1;
|
||||
switch(intValue) {
|
||||
case SOCKS4:
|
||||
comboProxyType->setCurrentIndex(1);
|
||||
break;
|
||||
case SOCKS5:
|
||||
case SOCKS5_PW:
|
||||
comboProxyType->setCurrentIndex(2);
|
||||
break;
|
||||
default:
|
||||
comboProxyType->setCurrentIndex(0);
|
||||
}
|
||||
}
|
||||
comboProxyType->setCurrentIndex(intValue);
|
||||
enablePeerProxy(intValue);
|
||||
enablePeerProxy(comboProxyType->currentIndex());
|
||||
//if(isProxyEnabled()) {
|
||||
// Proxy is enabled, save settings
|
||||
textProxyIP->setText(Preferences::getPeerProxyIp());
|
||||
|
@ -658,13 +668,18 @@ void options_imp::loadOptions(){
|
|||
enablePeerProxyAuth(checkProxyAuth->isChecked());
|
||||
//}
|
||||
intValue = Preferences::getHTTPProxyType();
|
||||
if(intValue <= 0) {
|
||||
intValue = 0;
|
||||
} else {
|
||||
intValue = 1;
|
||||
switch(intValue) {
|
||||
case HTTP:
|
||||
comboProxyType_http->setCurrentIndex(1);
|
||||
break;
|
||||
case SOCKS5:
|
||||
case SOCKS5_PW:
|
||||
comboProxyType_http->setCurrentIndex(2);
|
||||
break;
|
||||
default:
|
||||
comboProxyType_http->setCurrentIndex(0);
|
||||
}
|
||||
comboProxyType_http->setCurrentIndex(intValue);
|
||||
enableHTTPProxy(intValue);
|
||||
enableHTTPProxy(comboProxyType_http->currentIndex());
|
||||
textProxyUsername_http->setText(Preferences::getHTTPProxyUsername());
|
||||
textProxyPassword_http->setText(Preferences::getHTTPProxyPassword());
|
||||
textProxyIP_http->setText(Preferences::getHTTPProxyIp());
|
||||
|
|
|
@ -1951,8 +1951,8 @@ QGroupBox {
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>484</width>
|
||||
<height>312</height>
|
||||
<width>620</width>
|
||||
<height>495</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_16">
|
||||
|
@ -1983,6 +1983,11 @@ QGroupBox {
|
|||
<string>HTTP</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>SOCKS5</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
|
|
Loading…
Reference in a new issue