Browse Source

Fix to proxy settings

Added back SOCKS5 proxy support for HTTP communications
adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
296acf820c
  1. 12
      src/bittorrent.cpp
  2. 4
      src/downloadthread.cpp
  3. 57
      src/options_imp.cpp
  4. 9
      src/ui/options.ui

12
src/bittorrent.cpp

@ -538,6 +538,18 @@ void Bittorrent::configureSession() { @@ -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;
}

4
src/downloadthread.cpp

@ -35,6 +35,8 @@ @@ -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() { @@ -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 {

57
src/options_imp.cpp

@ -520,13 +520,22 @@ int options_imp::getPeerProxyType() const{ @@ -520,13 +520,22 @@ int options_imp::getPeerProxyType() const{
}
int options_imp::getHTTPProxyType() const {
if(comboProxyType_http->currentIndex() > 0){
if(isHTTPProxyAuthEnabled()){
return HTTP_PW;
switch(comboProxyType_http->currentIndex()) {
case 1: {
if(isHTTPProxyAuthEnabled()){
return HTTP_PW;
}
return HTTP;
}
case 2: {
if(isHTTPProxyAuthEnabled()) {
return SOCKS5_PW;
}
return SOCKS5;
}
return HTTP;
default:
return -1; // Disabled
}
return -1; // disabled
}
int options_imp::getStyle() const{
@ -637,17 +646,18 @@ void options_imp::loadOptions(){ @@ -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(){ @@ -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());

9
src/ui/options.ui

@ -1951,8 +1951,8 @@ QGroupBox { @@ -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 { @@ -1983,6 +1983,11 @@ QGroupBox {
<string>HTTP</string>
</property>
</item>
<item>
<property name="text">
<string>SOCKS5</string>
</property>
</item>
</widget>
</item>
<item>

Loading…
Cancel
Save