Browse Source

Add support for `allow_idna` option

Upstream PR: https://github.com/arvidn/libtorrent/pull/5316
adaptive-webui-19844
Chocobo1 4 years ago
parent
commit
20ae89c2a1
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 18
      src/base/bittorrent/session.cpp
  2. 7
      src/base/bittorrent/session.h
  3. 14
      src/gui/advancedsettings.cpp
  4. 2
      src/gui/advancedsettings.h
  5. 5
      src/webui/api/appcontroller.cpp
  6. 10
      src/webui/www/private/views/preferences.html

18
src/base/bittorrent/session.cpp

@ -387,6 +387,7 @@ Session::Session(QObject *parent)
, m_isUTPRateLimited(BITTORRENT_SESSION_KEY("uTPRateLimited"), true) , m_isUTPRateLimited(BITTORRENT_SESSION_KEY("uTPRateLimited"), true)
, m_utpMixedMode(BITTORRENT_SESSION_KEY("uTPMixedMode"), MixedModeAlgorithm::TCP , m_utpMixedMode(BITTORRENT_SESSION_KEY("uTPMixedMode"), MixedModeAlgorithm::TCP
, clampValue(MixedModeAlgorithm::TCP, MixedModeAlgorithm::Proportional)) , clampValue(MixedModeAlgorithm::TCP, MixedModeAlgorithm::Proportional))
, m_IDNSupportEnabled(BITTORRENT_SESSION_KEY("IDNSupportEnabled"), false)
, m_multiConnectionsPerIpEnabled(BITTORRENT_SESSION_KEY("MultiConnectionsPerIp"), false) , m_multiConnectionsPerIpEnabled(BITTORRENT_SESSION_KEY("MultiConnectionsPerIp"), false)
, m_validateHTTPSTrackerCertificate(BITTORRENT_SESSION_KEY("ValidateHTTPSTrackerCertificate"), false) , m_validateHTTPSTrackerCertificate(BITTORRENT_SESSION_KEY("ValidateHTTPSTrackerCertificate"), false)
, m_blockPeersOnPrivilegedPorts(BITTORRENT_SESSION_KEY("BlockPeersOnPrivilegedPorts"), false) , m_blockPeersOnPrivilegedPorts(BITTORRENT_SESSION_KEY("BlockPeersOnPrivilegedPorts"), false)
@ -1425,6 +1426,10 @@ void Session::loadLTSettings(lt::settings_pack &settingsPack)
break; break;
} }
#ifdef HAS_IDN_SUPPORT
settingsPack.set_bool(lt::settings_pack::allow_idna, isIDNSupportEnabled());
#endif
settingsPack.set_bool(lt::settings_pack::allow_multiple_connections_per_ip, multiConnectionsPerIpEnabled()); settingsPack.set_bool(lt::settings_pack::allow_multiple_connections_per_ip, multiConnectionsPerIpEnabled());
#ifdef HAS_HTTPS_TRACKER_VALIDATION #ifdef HAS_HTTPS_TRACKER_VALIDATION
@ -3698,6 +3703,19 @@ void Session::setUtpMixedMode(const MixedModeAlgorithm mode)
configureDeferred(); configureDeferred();
} }
bool Session::isIDNSupportEnabled() const
{
return m_IDNSupportEnabled;
}
void Session::setIDNSupportEnabled(const bool enabled)
{
if (enabled == m_IDNSupportEnabled) return;
m_IDNSupportEnabled = enabled;
configureDeferred();
}
bool Session::multiConnectionsPerIpEnabled() const bool Session::multiConnectionsPerIpEnabled() const
{ {
return m_multiConnectionsPerIpEnabled; return m_multiConnectionsPerIpEnabled;

7
src/base/bittorrent/session.h

@ -55,6 +55,10 @@
#define HAS_HTTPS_TRACKER_VALIDATION #define HAS_HTTPS_TRACKER_VALIDATION
#endif #endif
#if ((LIBTORRENT_VERSION_NUM >= 10212) && (LIBTORRENT_VERSION_NUM < 20000)) || (LIBTORRENT_VERSION_NUM >= 20002)
#define HAS_IDN_SUPPORT
#endif
class QFile; class QFile;
class QNetworkConfiguration; class QNetworkConfiguration;
class QNetworkConfigurationManager; class QNetworkConfigurationManager;
@ -417,6 +421,8 @@ namespace BitTorrent
void setUTPRateLimited(bool limited); void setUTPRateLimited(bool limited);
MixedModeAlgorithm utpMixedMode() const; MixedModeAlgorithm utpMixedMode() const;
void setUtpMixedMode(MixedModeAlgorithm mode); void setUtpMixedMode(MixedModeAlgorithm mode);
bool isIDNSupportEnabled() const;
void setIDNSupportEnabled(bool enabled);
bool multiConnectionsPerIpEnabled() const; bool multiConnectionsPerIpEnabled() const;
void setMultiConnectionsPerIpEnabled(bool enabled); void setMultiConnectionsPerIpEnabled(bool enabled);
bool validateHTTPSTrackerCertificate() const; bool validateHTTPSTrackerCertificate() const;
@ -688,6 +694,7 @@ namespace BitTorrent
CachedSettingValue<BTProtocol> m_btProtocol; CachedSettingValue<BTProtocol> m_btProtocol;
CachedSettingValue<bool> m_isUTPRateLimited; CachedSettingValue<bool> m_isUTPRateLimited;
CachedSettingValue<MixedModeAlgorithm> m_utpMixedMode; CachedSettingValue<MixedModeAlgorithm> m_utpMixedMode;
CachedSettingValue<bool> m_IDNSupportEnabled;
CachedSettingValue<bool> m_multiConnectionsPerIpEnabled; CachedSettingValue<bool> m_multiConnectionsPerIpEnabled;
CachedSettingValue<bool> m_validateHTTPSTrackerCertificate; CachedSettingValue<bool> m_validateHTTPSTrackerCertificate;
CachedSettingValue<bool> m_blockPeersOnPrivilegedPorts; CachedSettingValue<bool> m_blockPeersOnPrivilegedPorts;

14
src/gui/advancedsettings.cpp

@ -113,6 +113,9 @@ namespace
OUTGOING_PORT_MAX, OUTGOING_PORT_MAX,
UPNP_LEASE_DURATION, UPNP_LEASE_DURATION,
UTP_MIX_MODE, UTP_MIX_MODE,
#ifdef HAS_IDN_SUPPORT
IDN_SUPPORT,
#endif
MULTI_CONNECTIONS_PER_IP, MULTI_CONNECTIONS_PER_IP,
#ifdef HAS_HTTPS_TRACKER_VALIDATION #ifdef HAS_HTTPS_TRACKER_VALIDATION
VALIDATE_HTTPS_TRACKER_CERTIFICATE, VALIDATE_HTTPS_TRACKER_CERTIFICATE,
@ -223,6 +226,10 @@ void AdvancedSettings::saveAdvancedSettings()
session->setUPnPLeaseDuration(m_spinBoxUPnPLeaseDuration.value()); session->setUPnPLeaseDuration(m_spinBoxUPnPLeaseDuration.value());
// uTP-TCP mixed mode // uTP-TCP mixed mode
session->setUtpMixedMode(static_cast<BitTorrent::MixedModeAlgorithm>(m_comboBoxUtpMixedMode.currentIndex())); session->setUtpMixedMode(static_cast<BitTorrent::MixedModeAlgorithm>(m_comboBoxUtpMixedMode.currentIndex()));
#ifdef HAS_IDN_SUPPORT
// Support internationalized domain name (IDN)
session->setIDNSupportEnabled(m_checkBoxIDNSupport.isChecked());
#endif
// multiple connections per IP // multiple connections per IP
session->setMultiConnectionsPerIpEnabled(m_checkBoxMultiConnectionsPerIp.isChecked()); session->setMultiConnectionsPerIpEnabled(m_checkBoxMultiConnectionsPerIp.isChecked());
#ifdef HAS_HTTPS_TRACKER_VALIDATION #ifdef HAS_HTTPS_TRACKER_VALIDATION
@ -543,6 +550,13 @@ void AdvancedSettings::loadAdvancedSettings()
addRow(UTP_MIX_MODE, (tr("%1-TCP mixed mode algorithm", "uTP-TCP mixed mode algorithm").arg(C_UTP) addRow(UTP_MIX_MODE, (tr("%1-TCP mixed mode algorithm", "uTP-TCP mixed mode algorithm").arg(C_UTP)
+ ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#mixed_mode_algorithm", "(?)")) + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#mixed_mode_algorithm", "(?)"))
, &m_comboBoxUtpMixedMode); , &m_comboBoxUtpMixedMode);
#ifdef HAS_IDN_SUPPORT
// Support internationalized domain name (IDN)
m_checkBoxIDNSupport.setChecked(session->isIDNSupportEnabled());
addRow(IDN_SUPPORT, (tr("Support internationalized domain name (IDN)")
+ ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#allow_idna", "(?)"))
, &m_checkBoxIDNSupport);
#endif
// multiple connections per IP // multiple connections per IP
m_checkBoxMultiConnectionsPerIp.setChecked(session->multiConnectionsPerIpEnabled()); m_checkBoxMultiConnectionsPerIp.setChecked(session->multiConnectionsPerIpEnabled());
addRow(MULTI_CONNECTIONS_PER_IP, (tr("Allow multiple connections from the same IP address") addRow(MULTI_CONNECTIONS_PER_IP, (tr("Allow multiple connections from the same IP address")

2
src/gui/advancedsettings.h

@ -70,7 +70,7 @@ private:
m_checkBoxProgramNotifications, m_checkBoxTorrentAddedNotifications, m_checkBoxTrackerFavicon, m_checkBoxTrackerStatus, m_checkBoxProgramNotifications, m_checkBoxTorrentAddedNotifications, m_checkBoxTrackerFavicon, m_checkBoxTrackerStatus,
m_checkBoxConfirmTorrentRecheck, m_checkBoxConfirmRemoveAllTags, m_checkBoxAnnounceAllTrackers, m_checkBoxAnnounceAllTiers, m_checkBoxConfirmTorrentRecheck, m_checkBoxConfirmRemoveAllTags, m_checkBoxAnnounceAllTrackers, m_checkBoxAnnounceAllTiers,
m_checkBoxMultiConnectionsPerIp, m_checkBoxValidateHTTPSTrackerCertificate, m_checkBoxBlockPeersOnPrivilegedPorts, m_checkBoxPieceExtentAffinity, m_checkBoxMultiConnectionsPerIp, m_checkBoxValidateHTTPSTrackerCertificate, m_checkBoxBlockPeersOnPrivilegedPorts, m_checkBoxPieceExtentAffinity,
m_checkBoxSuggestMode, m_checkBoxSpeedWidgetEnabled; m_checkBoxSuggestMode, m_checkBoxSpeedWidgetEnabled, m_checkBoxIDNSupport;
QComboBox m_comboBoxInterface, m_comboBoxInterfaceAddress, m_comboBoxUtpMixedMode, m_comboBoxChokingAlgorithm, m_comboBoxSeedChokingAlgorithm; QComboBox m_comboBoxInterface, m_comboBoxInterfaceAddress, m_comboBoxUtpMixedMode, m_comboBoxChokingAlgorithm, m_comboBoxSeedChokingAlgorithm;
QLineEdit m_lineEditAnnounceIP; QLineEdit m_lineEditAnnounceIP;

5
src/webui/api/appcontroller.cpp

@ -309,6 +309,8 @@ void AppController::preferencesAction()
data["upnp_lease_duration"] = session->UPnPLeaseDuration(); data["upnp_lease_duration"] = session->UPnPLeaseDuration();
// uTP-TCP mixed mode // uTP-TCP mixed mode
data["utp_tcp_mixed_mode"] = static_cast<int>(session->utpMixedMode()); data["utp_tcp_mixed_mode"] = static_cast<int>(session->utpMixedMode());
// Support internationalized domain name (IDN)
data["idn_support_enabled"] = session->isIDNSupportEnabled();
// Multiple connections per IP // Multiple connections per IP
data["enable_multi_connections_from_same_ip"] = session->multiConnectionsPerIpEnabled(); data["enable_multi_connections_from_same_ip"] = session->multiConnectionsPerIpEnabled();
// Validate HTTPS tracker certificate // Validate HTTPS tracker certificate
@ -771,6 +773,9 @@ void AppController::setPreferencesAction()
// uTP-TCP mixed mode // uTP-TCP mixed mode
if (hasKey("utp_tcp_mixed_mode")) if (hasKey("utp_tcp_mixed_mode"))
session->setUtpMixedMode(static_cast<BitTorrent::MixedModeAlgorithm>(it.value().toInt())); session->setUtpMixedMode(static_cast<BitTorrent::MixedModeAlgorithm>(it.value().toInt()));
// Support internationalized domain name (IDN)
if (hasKey("idn_support_enabled"))
session->setIDNSupportEnabled(it.value().toBool());
// Multiple connections per IP // Multiple connections per IP
if (hasKey("enable_multi_connections_from_same_ip")) if (hasKey("enable_multi_connections_from_same_ip"))
session->setMultiConnectionsPerIpEnabled(it.value().toBool()); session->setMultiConnectionsPerIpEnabled(it.value().toBool());

10
src/webui/www/private/views/preferences.html

@ -1099,6 +1099,14 @@
</select> </select>
</td> </td>
</tr> </tr>
<tr>
<td>
<label for="IDNSupportCheckbox">QBT_TR(Support internationalized domain name (IDN) (requires libtorrent >= 1.2.12):)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#allow_idna" target="_blank">(?)</a></label>
</td>
<td>
<input type="checkbox" id="IDNSupportCheckbox" />
</td>
</tr>
<tr> <tr>
<td> <td>
<label for="allowMultipleConnectionsFromTheSameIPAddress">QBT_TR(Allow multiple connections from the same IP address:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#allow_multiple_connections_per_ip" target="_blank">(?)</a></label> <label for="allowMultipleConnectionsFromTheSameIPAddress">QBT_TR(Allow multiple connections from the same IP address:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#allow_multiple_connections_per_ip" target="_blank">(?)</a></label>
@ -1895,6 +1903,7 @@
$('outgoingPortsMax').setProperty('value', pref.outgoing_ports_max); $('outgoingPortsMax').setProperty('value', pref.outgoing_ports_max);
$('UPnPLeaseDuration').setProperty('value', pref.upnp_lease_duration); $('UPnPLeaseDuration').setProperty('value', pref.upnp_lease_duration);
$('utpTCPMixedModeAlgorithm').setProperty('value', pref.utp_tcp_mixed_mode); $('utpTCPMixedModeAlgorithm').setProperty('value', pref.utp_tcp_mixed_mode);
$('IDNSupportCheckbox').setProperty('checked', pref.idn_support_enabled);
$('allowMultipleConnectionsFromTheSameIPAddress').setProperty('checked', pref.enable_multi_connections_from_same_ip); $('allowMultipleConnectionsFromTheSameIPAddress').setProperty('checked', pref.enable_multi_connections_from_same_ip);
$('validateHTTPSTrackerCertificate').setProperty('checked', pref.validate_https_tracker_certificate); $('validateHTTPSTrackerCertificate').setProperty('checked', pref.validate_https_tracker_certificate);
$('blockPeersOnPrivilegedPorts').setProperty('checked', pref.block_peers_on_privileged_ports); $('blockPeersOnPrivilegedPorts').setProperty('checked', pref.block_peers_on_privileged_ports);
@ -2282,6 +2291,7 @@
settings.set('outgoing_ports_max', $('outgoingPortsMax').getProperty('value')); settings.set('outgoing_ports_max', $('outgoingPortsMax').getProperty('value'));
settings.set('upnp_lease_duration', $('UPnPLeaseDuration').getProperty('value')); settings.set('upnp_lease_duration', $('UPnPLeaseDuration').getProperty('value'));
settings.set('utp_tcp_mixed_mode', $('utpTCPMixedModeAlgorithm').getProperty('value')); settings.set('utp_tcp_mixed_mode', $('utpTCPMixedModeAlgorithm').getProperty('value'));
settings.set('idn_support_enabled', $('IDNSupportCheckbox').getProperty('checked'));
settings.set('enable_multi_connections_from_same_ip', $('allowMultipleConnectionsFromTheSameIPAddress').getProperty('checked')); settings.set('enable_multi_connections_from_same_ip', $('allowMultipleConnectionsFromTheSameIPAddress').getProperty('checked'));
settings.set('validate_https_tracker_certificate', $('validateHTTPSTrackerCertificate').getProperty('checked')); settings.set('validate_https_tracker_certificate', $('validateHTTPSTrackerCertificate').getProperty('checked'));
settings.set('block_peers_on_privileged_ports', $('blockPeersOnPrivilegedPorts').getProperty('checked')); settings.set('block_peers_on_privileged_ports', $('blockPeersOnPrivilegedPorts').getProperty('checked'));

Loading…
Cancel
Save