diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index 000a8ce9c..a23009fbb 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -387,6 +387,7 @@ Session::Session(QObject *parent) , m_isUTPRateLimited(BITTORRENT_SESSION_KEY("uTPRateLimited"), true) , m_utpMixedMode(BITTORRENT_SESSION_KEY("uTPMixedMode"), MixedModeAlgorithm::TCP , clampValue(MixedModeAlgorithm::TCP, MixedModeAlgorithm::Proportional)) + , m_IDNSupportEnabled(BITTORRENT_SESSION_KEY("IDNSupportEnabled"), false) , m_multiConnectionsPerIpEnabled(BITTORRENT_SESSION_KEY("MultiConnectionsPerIp"), false) , m_validateHTTPSTrackerCertificate(BITTORRENT_SESSION_KEY("ValidateHTTPSTrackerCertificate"), false) , m_blockPeersOnPrivilegedPorts(BITTORRENT_SESSION_KEY("BlockPeersOnPrivilegedPorts"), false) @@ -1425,6 +1426,10 @@ void Session::loadLTSettings(lt::settings_pack &settingsPack) 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()); #ifdef HAS_HTTPS_TRACKER_VALIDATION @@ -3698,6 +3703,19 @@ void Session::setUtpMixedMode(const MixedModeAlgorithm mode) 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 { return m_multiConnectionsPerIpEnabled; diff --git a/src/base/bittorrent/session.h b/src/base/bittorrent/session.h index d63188c94..9491f2684 100644 --- a/src/base/bittorrent/session.h +++ b/src/base/bittorrent/session.h @@ -51,10 +51,14 @@ #include "sessionstatus.h" #include "torrentinfo.h" -#if !defined(Q_OS_WIN) +#if !defined(Q_OS_WIN) || (LIBTORRENT_VERSION_NUM >= 10212) #define HAS_HTTPS_TRACKER_VALIDATION #endif +#if ((LIBTORRENT_VERSION_NUM >= 10212) && (LIBTORRENT_VERSION_NUM < 20000)) || (LIBTORRENT_VERSION_NUM >= 20002) +#define HAS_IDN_SUPPORT +#endif + class QFile; class QNetworkConfiguration; class QNetworkConfigurationManager; @@ -417,6 +421,8 @@ namespace BitTorrent void setUTPRateLimited(bool limited); MixedModeAlgorithm utpMixedMode() const; void setUtpMixedMode(MixedModeAlgorithm mode); + bool isIDNSupportEnabled() const; + void setIDNSupportEnabled(bool enabled); bool multiConnectionsPerIpEnabled() const; void setMultiConnectionsPerIpEnabled(bool enabled); bool validateHTTPSTrackerCertificate() const; @@ -688,6 +694,7 @@ namespace BitTorrent CachedSettingValue m_btProtocol; CachedSettingValue m_isUTPRateLimited; CachedSettingValue m_utpMixedMode; + CachedSettingValue m_IDNSupportEnabled; CachedSettingValue m_multiConnectionsPerIpEnabled; CachedSettingValue m_validateHTTPSTrackerCertificate; CachedSettingValue m_blockPeersOnPrivilegedPorts; diff --git a/src/gui/advancedsettings.cpp b/src/gui/advancedsettings.cpp index 126aba8e6..e70340246 100644 --- a/src/gui/advancedsettings.cpp +++ b/src/gui/advancedsettings.cpp @@ -113,6 +113,9 @@ namespace OUTGOING_PORT_MAX, UPNP_LEASE_DURATION, UTP_MIX_MODE, +#ifdef HAS_IDN_SUPPORT + IDN_SUPPORT, +#endif MULTI_CONNECTIONS_PER_IP, #ifdef HAS_HTTPS_TRACKER_VALIDATION VALIDATE_HTTPS_TRACKER_CERTIFICATE, @@ -223,6 +226,10 @@ void AdvancedSettings::saveAdvancedSettings() session->setUPnPLeaseDuration(m_spinBoxUPnPLeaseDuration.value()); // uTP-TCP mixed mode session->setUtpMixedMode(static_cast(m_comboBoxUtpMixedMode.currentIndex())); +#ifdef HAS_IDN_SUPPORT + // Support internationalized domain name (IDN) + session->setIDNSupportEnabled(m_checkBoxIDNSupport.isChecked()); +#endif // multiple connections per IP session->setMultiConnectionsPerIpEnabled(m_checkBoxMultiConnectionsPerIp.isChecked()); #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) + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#mixed_mode_algorithm", "(?)")) , &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 m_checkBoxMultiConnectionsPerIp.setChecked(session->multiConnectionsPerIpEnabled()); addRow(MULTI_CONNECTIONS_PER_IP, (tr("Allow multiple connections from the same IP address") diff --git a/src/gui/advancedsettings.h b/src/gui/advancedsettings.h index 857ceb6c0..06f9b91c4 100644 --- a/src/gui/advancedsettings.h +++ b/src/gui/advancedsettings.h @@ -70,7 +70,7 @@ private: m_checkBoxProgramNotifications, m_checkBoxTorrentAddedNotifications, m_checkBoxTrackerFavicon, m_checkBoxTrackerStatus, m_checkBoxConfirmTorrentRecheck, m_checkBoxConfirmRemoveAllTags, m_checkBoxAnnounceAllTrackers, m_checkBoxAnnounceAllTiers, 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; QLineEdit m_lineEditAnnounceIP; diff --git a/src/webui/api/appcontroller.cpp b/src/webui/api/appcontroller.cpp index c50d7ce22..a5298e7a3 100644 --- a/src/webui/api/appcontroller.cpp +++ b/src/webui/api/appcontroller.cpp @@ -309,6 +309,8 @@ void AppController::preferencesAction() data["upnp_lease_duration"] = session->UPnPLeaseDuration(); // uTP-TCP mixed mode data["utp_tcp_mixed_mode"] = static_cast(session->utpMixedMode()); + // Support internationalized domain name (IDN) + data["idn_support_enabled"] = session->isIDNSupportEnabled(); // Multiple connections per IP data["enable_multi_connections_from_same_ip"] = session->multiConnectionsPerIpEnabled(); // Validate HTTPS tracker certificate @@ -771,6 +773,9 @@ void AppController::setPreferencesAction() // uTP-TCP mixed mode if (hasKey("utp_tcp_mixed_mode")) session->setUtpMixedMode(static_cast(it.value().toInt())); + // Support internationalized domain name (IDN) + if (hasKey("idn_support_enabled")) + session->setIDNSupportEnabled(it.value().toBool()); // Multiple connections per IP if (hasKey("enable_multi_connections_from_same_ip")) session->setMultiConnectionsPerIpEnabled(it.value().toBool()); diff --git a/src/webui/www/private/views/preferences.html b/src/webui/www/private/views/preferences.html index a8cf6a83b..504211ec0 100644 --- a/src/webui/www/private/views/preferences.html +++ b/src/webui/www/private/views/preferences.html @@ -1099,6 +1099,14 @@ + + + + + + + + @@ -1895,6 +1903,7 @@ $('outgoingPortsMax').setProperty('value', pref.outgoing_ports_max); $('UPnPLeaseDuration').setProperty('value', pref.upnp_lease_duration); $('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); $('validateHTTPSTrackerCertificate').setProperty('checked', pref.validate_https_tracker_certificate); $('blockPeersOnPrivilegedPorts').setProperty('checked', pref.block_peers_on_privileged_ports); @@ -2282,6 +2291,7 @@ settings.set('outgoing_ports_max', $('outgoingPortsMax').getProperty('value')); settings.set('upnp_lease_duration', $('UPnPLeaseDuration').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('validate_https_tracker_certificate', $('validateHTTPSTrackerCertificate').getProperty('checked')); settings.set('block_peers_on_privileged_ports', $('blockPeersOnPrivilegedPorts').getProperty('checked'));