Browse Source

- FEATURE: Allow to set a different port for DHT (UDP) than the one used for

Bittorrent
adaptive-webui-19844
Christophe Dumez 16 years ago
parent
commit
ee6bc3c2e9
  1. 1
      Changelog
  2. 9
      src/GUI.cpp
  3. 4
      src/bittorrent.cpp
  4. 73
      src/options.ui
  5. 30
      src/options_imp.cpp
  6. 3
      src/options_imp.h

1
Changelog

@ -5,6 +5,7 @@
- FEATURE: Resizing a column in a search results tab affects all tabs - FEATURE: Resizing a column in a search results tab affects all tabs
- FEATURE: Search results tab columns are now remembered upon startup - FEATURE: Search results tab columns are now remembered upon startup
- FEATURE: Added right click menu in search engine to clear completion history - FEATURE: Added right click menu in search engine to clear completion history
- FEATURE: Allow to set a different port for DHT (UDP) than the one used for Bittorrent
- BUGFIX: Provide more helpful explanation when an I/O error occured - BUGFIX: Provide more helpful explanation when an I/O error occured
- BUGFIX: Stop enforcing UTF-8 and use system locale instead - BUGFIX: Stop enforcing UTF-8 and use system locale instead
- COSMETIC: Redesigned program preferences - COSMETIC: Redesigned program preferences

9
src/GUI.cpp

@ -990,7 +990,7 @@ void GUI::configureSession(bool deleteOptions) {
BTSession->setListeningPortsRange(options->getPorts()); BTSession->setListeningPortsRange(options->getPorts());
unsigned short new_listenPort = BTSession->getListenPort(); unsigned short new_listenPort = BTSession->getListenPort();
if(new_listenPort != old_listenPort) { if(new_listenPort != old_listenPort) {
BTSession->addConsoleMessage(tr("qBittorrent is bind to port: %1", "e.g: qBittorrent is bind to port: 1666").arg( misc::toQString(new_listenPort))); BTSession->addConsoleMessage(tr("qBittorrent is bound to port: TCP/%1", "e.g: qBittorrent is bound to port: 6881").arg( misc::toQString(new_listenPort)));
} }
// * Global download limit // * Global download limit
QPair<int, int> limits = options->getGlobalBandwidthLimits(); QPair<int, int> limits = options->getGlobalBandwidthLimits();
@ -1079,9 +1079,12 @@ void GUI::configureSession(bool deleteOptions) {
// * DHT // * DHT
if(options->isDHTEnabled()) { if(options->isDHTEnabled()) {
// Set DHT Port // Set DHT Port
BTSession->setDHTPort(new_listenPort); BTSession->setDHTPort(options->getDHTPort());
if(BTSession->enableDHT(true)) { if(BTSession->enableDHT(true)) {
BTSession->addConsoleMessage(tr("DHT support [ON], port: %1").arg(new_listenPort), QString::fromUtf8("blue")); int dht_port = new_listenPort;
if(options->getDHTPort())
dht_port = options->getDHTPort();
BTSession->addConsoleMessage(tr("DHT support [ON], port: UDP/%1").arg(dht_port), QString::fromUtf8("blue"));
} else { } else {
BTSession->addConsoleMessage(tr("DHT support [OFF]"), QString::fromUtf8("red")); BTSession->addConsoleMessage(tr("DHT support [OFF]"), QString::fromUtf8("red"));
} }

4
src/bittorrent.cpp

@ -1072,9 +1072,9 @@ void bittorrent::saveTrackerFile(QString hash) {
tracker_file.close(); tracker_file.close();
} }
// Set DHT port (>= 1000) // Set DHT port (>= 1000 or 0 if same as BT)
void bittorrent::setDHTPort(int dht_port) { void bittorrent::setDHTPort(int dht_port) {
if(dht_port >= 1000) { if(dht_port == 0 or dht_port >= 1000) {
struct dht_settings DHTSettings; struct dht_settings DHTSettings;
DHTSettings.service_port = dht_port; DHTSettings.service_port = dht_port;
s->set_dht_settings(DHTSettings); s->set_dht_settings(DHTSettings);

73
src/options.ui

@ -1429,13 +1429,13 @@
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="tabOptionPage4"> <widget class="QWidget" name="tabOptionPage4">
<layout class="QVBoxLayout"> <layout class="QVBoxLayout" name="verticalLayout_15">
<item> <item>
<widget class="QGroupBox" name="AddBTFeaturesBox"> <widget class="QGroupBox" name="AddBTFeaturesBox">
<property name="title"> <property name="title">
<string>Bittorrent features</string> <string>Bittorrent features</string>
</property> </property>
<layout class="QVBoxLayout"> <layout class="QVBoxLayout" name="verticalLayout_14">
<item> <item>
<widget class="QCheckBox" name="checkDHT"> <widget class="QCheckBox" name="checkDHT">
<property name="text"> <property name="text">
@ -1446,6 +1446,75 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="checkSameDHTPort">
<property name="text">
<string>Use the same port for DHT and Bittorrent</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>13</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="dh_port_lbl">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>DHT port:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinDHTPort">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimum">
<number>1000</number>
</property>
<property name="maximum">
<number>65525</number>
</property>
<property name="value">
<number>6882</number>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item> <item>
<widget class="QCheckBox" name="checkLSD"> <widget class="QCheckBox" name="checkLSD">
<property name="text"> <property name="text">

30
src/options_imp.cpp

@ -153,6 +153,7 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){
connect(checkMaxUploadsPerTorrent, SIGNAL(stateChanged(int)), this, SLOT(enableMaxUploadsLimitPerTorrent(int))); connect(checkMaxUploadsPerTorrent, SIGNAL(stateChanged(int)), this, SLOT(enableMaxUploadsLimitPerTorrent(int)));
connect(checkRatioLimit, SIGNAL(stateChanged(int)), this, SLOT(enableShareRatio(int))); connect(checkRatioLimit, SIGNAL(stateChanged(int)), this, SLOT(enableShareRatio(int)));
connect(checkRatioRemove, SIGNAL(stateChanged(int)), this, SLOT(enableDeleteRatio(int))); connect(checkRatioRemove, SIGNAL(stateChanged(int)), this, SLOT(enableDeleteRatio(int)));
connect(checkSameDHTPort, SIGNAL(stateChanged(int)), this, SLOT(enableDHTPortSettings(int)));
// Proxy tab // Proxy tab
connect(comboProxyType_http, SIGNAL(currentIndexChanged(int)),this, SLOT(enableProxyHTTP(int))); connect(comboProxyType_http, SIGNAL(currentIndexChanged(int)),this, SLOT(enableProxyHTTP(int)));
connect(checkProxyAuth_http, SIGNAL(stateChanged(int)), this, SLOT(enableProxyAuthHTTP(int))); connect(checkProxyAuth_http, SIGNAL(stateChanged(int)), this, SLOT(enableProxyAuthHTTP(int)));
@ -202,6 +203,8 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){
connect(spinMaxConnecPerTorrent, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton())); connect(spinMaxConnecPerTorrent, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton()));
connect(spinMaxUploadsPerTorrent, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton())); connect(spinMaxUploadsPerTorrent, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton()));
connect(checkDHT, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton())); connect(checkDHT, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
connect(checkSameDHTPort, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
connect(spinDHTPort, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton()));
connect(checkLSD, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton())); connect(checkLSD, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
connect(checkAzureusSpoof, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton())); connect(checkAzureusSpoof, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
connect(comboEncryption, SIGNAL(currentIndexChanged(int)), this, SLOT(enableApplyButton())); connect(comboEncryption, SIGNAL(currentIndexChanged(int)), this, SLOT(enableApplyButton()));
@ -396,6 +399,8 @@ void options_imp::saveOptions(){
settings.setValue(QString::fromUtf8("MaxConnecsPerTorrent"), getMaxConnecsPerTorrent()); settings.setValue(QString::fromUtf8("MaxConnecsPerTorrent"), getMaxConnecsPerTorrent());
settings.setValue(QString::fromUtf8("MaxUploadsPerTorrent"), getMaxUploadsPerTorrent()); settings.setValue(QString::fromUtf8("MaxUploadsPerTorrent"), getMaxUploadsPerTorrent());
settings.setValue(QString::fromUtf8("DHT"), isDHTEnabled()); settings.setValue(QString::fromUtf8("DHT"), isDHTEnabled());
settings.setValue(QString::fromUtf8("sameDHTPortAsBT"), isDHTPortSameAsBT());
settings.setValue(QString::fromUtf8("DHTPort"), getDHTPort());
settings.setValue(QString::fromUtf8("LSD"), isLSDEnabled()); settings.setValue(QString::fromUtf8("LSD"), isLSDEnabled());
settings.setValue(QString::fromUtf8("AzureusSpoof"), shouldSpoofAzureus()); settings.setValue(QString::fromUtf8("AzureusSpoof"), shouldSpoofAzureus());
settings.setValue(QString::fromUtf8("Encryption"), getEncryptionSetting()); settings.setValue(QString::fromUtf8("Encryption"), getEncryptionSetting());
@ -696,6 +701,9 @@ void options_imp::loadOptions(){
spinMaxUploadsPerTorrent->setEnabled(false); spinMaxUploadsPerTorrent->setEnabled(false);
} }
checkDHT->setChecked(settings.value(QString::fromUtf8("DHT"), true).toBool()); checkDHT->setChecked(settings.value(QString::fromUtf8("DHT"), true).toBool());
checkSameDHTPort->setChecked(settings.value(QString::fromUtf8("sameDHTPortAsBT"), true).toBool());
enableDHTPortSettings(checkSameDHTPort->checkState());
spinDHTPort->setValue(settings.value(QString::fromUtf8("DHTPort"), 6882).toInt());
checkLSD->setChecked(settings.value(QString::fromUtf8("LSD"), true).toBool()); checkLSD->setChecked(settings.value(QString::fromUtf8("LSD"), true).toBool());
checkAzureusSpoof->setChecked(settings.value(QString::fromUtf8("AzureusSpoof"), false).toBool()); checkAzureusSpoof->setChecked(settings.value(QString::fromUtf8("AzureusSpoof"), false).toBool());
comboEncryption->setCurrentIndex(settings.value(QString::fromUtf8("Encryption"), 0).toInt()); comboEncryption->setCurrentIndex(settings.value(QString::fromUtf8("Encryption"), 0).toInt());
@ -867,6 +875,12 @@ bool options_imp::systrayIntegration() const{
return (!checkNoSystray->isChecked()); return (!checkNoSystray->isChecked());
} }
int options_imp::getDHTPort() const {
if(isDHTPortSameAsBT())
return 0;
return spinDHTPort->value();
}
// Return Share ratio // Return Share ratio
float options_imp::getDesiredRatio() const{ float options_imp::getDesiredRatio() const{
if(checkRatioLimit->isChecked()){ if(checkRatioLimit->isChecked()){
@ -1108,6 +1122,18 @@ void options_imp::enableShareRatio(int checkBoxValue){
} }
} }
void options_imp::enableDHTPortSettings(int checkBoxValue) {
if(checkBoxValue != 2){
//Disable
spinDHTPort->setEnabled(false);
dh_port_lbl->setEnabled(false);
}else{
//enable
spinDHTPort->setEnabled(true);
dh_port_lbl->setEnabled(true);
}
}
void options_imp::enableDeleteRatio(int checkBoxValue){ void options_imp::enableDeleteRatio(int checkBoxValue){
if(checkBoxValue != 2){ if(checkBoxValue != 2){
//Disable //Disable
@ -1214,6 +1240,10 @@ bool options_imp::addTorrentsInPause() const {
return checkStartPaused->isChecked(); return checkStartPaused->isChecked();
} }
bool options_imp::isDHTPortSameAsBT() const {
return checkSameDHTPort->isChecked();
}
// Proxy settings // Proxy settings
bool options_imp::isProxyEnabled() const{ bool options_imp::isProxyEnabled() const{
return comboProxyType->currentIndex(); return comboProxyType->currentIndex();

3
src/options_imp.h

@ -97,6 +97,8 @@ class options_imp : public QDialog, private Ui::Dialog {
int getMaxConnecsPerTorrent() const; int getMaxConnecsPerTorrent() const;
int getMaxUploadsPerTorrent() const; int getMaxUploadsPerTorrent() const;
bool isDHTEnabled() const; bool isDHTEnabled() const;
bool isDHTPortSameAsBT() const;
int getDHTPort() const;
bool isPeXEnabled() const; bool isPeXEnabled() const;
bool isLSDEnabled() const; bool isLSDEnabled() const;
bool isRSSEnabled() const; bool isRSSEnabled() const;
@ -152,6 +154,7 @@ class options_imp : public QDialog, private Ui::Dialog {
void enableDeleteRatio(int checkBoxValue); void enableDeleteRatio(int checkBoxValue);
void enableFilter(int checkBoxValue); void enableFilter(int checkBoxValue);
void enableRSS(int checkBoxValue); void enableRSS(int checkBoxValue);
void enableDHTPortSettings(int checkBoxValue);
void enableQueueingSystem(int checkBoxValue); void enableQueueingSystem(int checkBoxValue);
void setStyle(int style); void setStyle(int style);
void on_buttonBox_accepted(); void on_buttonBox_accepted();

Loading…
Cancel
Save