1
mirror of https://github.com/qbittorrent/qBittorrent synced 2024-10-17 13:01:11 +02:00

Merge pull request #14493 from Chocobo1/tos

Expose ToS setting from libtorrent
This commit is contained in:
Mike Tzou 2021-03-08 10:24:42 +08:00 committed by GitHub
commit f3435c5e35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 47 additions and 4 deletions

View File

@ -372,6 +372,7 @@ Session::Session(QObject *parent)
, m_outgoingPortsMin(BITTORRENT_SESSION_KEY("OutgoingPortsMin"), 0)
, m_outgoingPortsMax(BITTORRENT_SESSION_KEY("OutgoingPortsMax"), 0)
, m_UPnPLeaseDuration(BITTORRENT_SESSION_KEY("UPnPLeaseDuration"), 0)
, m_peerToS(BITTORRENT_SESSION_KEY("PeerToS"), 0x20)
, m_ignoreLimitsOnLAN(BITTORRENT_SESSION_KEY("IgnoreLimitsOnLAN"), false)
, m_includeOverheadInLimits(BITTORRENT_SESSION_KEY("IncludeOverheadInLimits"), false)
, m_announceIP(BITTORRENT_SESSION_KEY("AnnounceIP"))
@ -1335,9 +1336,10 @@ void Session::loadLTSettings(lt::settings_pack &settingsPack)
// Outgoing ports
settingsPack.set_int(lt::settings_pack::outgoing_port, outgoingPortsMin());
settingsPack.set_int(lt::settings_pack::num_outgoing_ports, outgoingPortsMax() - outgoingPortsMin() + 1);
// UPnP lease duration
settingsPack.set_int(lt::settings_pack::upnp_lease_duration, UPnPLeaseDuration());
// Type of service
settingsPack.set_int(lt::settings_pack::peer_tos, peerToS());
// Include overhead in transfer limits
settingsPack.set_bool(lt::settings_pack::rate_limit_ip_overhead, includeOverheadInLimits());
// IP address to announce to trackers
@ -3516,6 +3518,20 @@ void Session::setUPnPLeaseDuration(const int duration)
}
}
int Session::peerToS() const
{
return m_peerToS;
}
void Session::setPeerToS(const int value)
{
if (value == m_peerToS)
return;
m_peerToS = value;
configureDeferred();
}
bool Session::ignoreLimitsOnLAN() const
{
return m_ignoreLimitsOnLAN;

View File

@ -384,6 +384,8 @@ namespace BitTorrent
void setOutgoingPortsMax(int max);
int UPnPLeaseDuration() const;
void setUPnPLeaseDuration(int duration);
int peerToS() const;
void setPeerToS(int value);
bool ignoreLimitsOnLAN() const;
void setIgnoreLimitsOnLAN(bool ignore);
bool includeOverheadInLimits() const;
@ -673,6 +675,7 @@ namespace BitTorrent
CachedSettingValue<int> m_outgoingPortsMin;
CachedSettingValue<int> m_outgoingPortsMax;
CachedSettingValue<int> m_UPnPLeaseDuration;
CachedSettingValue<int> m_peerToS;
CachedSettingValue<bool> m_ignoreLimitsOnLAN;
CachedSettingValue<bool> m_includeOverheadInLimits;
CachedSettingValue<QString> m_announceIP;

View File

@ -115,6 +115,7 @@ namespace
OUTGOING_PORT_MIN,
OUTGOING_PORT_MAX,
UPNP_LEASE_DURATION,
PEER_TOS,
UTP_MIX_MODE,
IDN_SUPPORT,
MULTI_CONNECTIONS_PER_IP,
@ -223,6 +224,8 @@ void AdvancedSettings::saveAdvancedSettings()
session->setOutgoingPortsMax(m_spinBoxOutgoingPortsMax.value());
// UPnP lease duration
session->setUPnPLeaseDuration(m_spinBoxUPnPLeaseDuration.value());
// Type of service
session->setPeerToS(m_spinBoxPeerToS.value());
// uTP-TCP mixed mode
session->setUtpMixedMode(static_cast<BitTorrent::MixedModeAlgorithm>(m_comboBoxUtpMixedMode.currentIndex()));
// Support internationalized domain name (IDN)
@ -542,6 +545,12 @@ void AdvancedSettings::loadAdvancedSettings()
m_spinBoxUPnPLeaseDuration.setSuffix(tr(" s", " seconds"));
addRow(UPNP_LEASE_DURATION, (tr("UPnP lease duration [0: Permanent lease]") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#upnp_lease_duration", "(?)"))
, &m_spinBoxUPnPLeaseDuration);
// Type of service
m_spinBoxPeerToS.setMinimum(0);
m_spinBoxPeerToS.setMaximum(255);
m_spinBoxPeerToS.setValue(session->peerToS());
addRow(PEER_TOS, (tr("Type of service (ToS) for connections to peers") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#peer_tos", "(?)"))
, &m_spinBoxPeerToS);
// uTP-TCP mixed mode
m_comboBoxUtpMixedMode.addItems({tr("Prefer TCP"), tr("Peer proportional (throttles TCP)")});
m_comboBoxUtpMixedMode.setCurrentIndex(static_cast<int>(session->utpMixedMode()));

View File

@ -61,7 +61,7 @@ private:
template <typename T> void addRow(int row, const QString &text, T *widget);
QSpinBox m_spinBoxAsyncIOThreads, m_spinBoxFilePoolSize, m_spinBoxCheckingMemUsage,
m_spinBoxSaveResumeDataInterval, m_spinBoxOutgoingPortsMin, m_spinBoxOutgoingPortsMax, m_spinBoxUPnPLeaseDuration,
m_spinBoxSaveResumeDataInterval, m_spinBoxOutgoingPortsMin, m_spinBoxOutgoingPortsMax, m_spinBoxUPnPLeaseDuration, m_spinBoxPeerToS,
m_spinBoxListRefresh, m_spinBoxTrackerPort, m_spinBoxSendBufferWatermark, m_spinBoxSendBufferLowWatermark,
m_spinBoxSendBufferWatermarkFactor, m_spinBoxSocketBacklogSize, m_spinBoxMaxConcurrentHTTPAnnounces, m_spinBoxStopTrackerTimeout,
m_spinBoxSavePathHistoryLength, m_spinBoxPeerTurnover, m_spinBoxPeerTurnoverCutoff, m_spinBoxPeerTurnoverInterval;

View File

@ -309,6 +309,8 @@ void AppController::preferencesAction()
data["outgoing_ports_max"] = session->outgoingPortsMax();
// UPnP lease duration
data["upnp_lease_duration"] = session->UPnPLeaseDuration();
// Type of service
data["peer_tos"] = session->peerToS();
// uTP-TCP mixed mode
data["utp_tcp_mixed_mode"] = static_cast<int>(session->utpMixedMode());
// Support internationalized domain name (IDN)
@ -772,6 +774,9 @@ void AppController::setPreferencesAction()
// UPnP lease duration
if (hasKey("upnp_lease_duration"))
session->setUPnPLeaseDuration(it.value().toInt());
// Type of service
if (hasKey("peer_tos"))
session->setPeerToS(it.value().toInt());
// uTP-TCP mixed mode
if (hasKey("utp_tcp_mixed_mode"))
session->setUtpMixedMode(static_cast<BitTorrent::MixedModeAlgorithm>(it.value().toInt()));

View File

@ -58,7 +58,7 @@
$('renameButton').disabled = true;
const parentPath = window.qBittorrent.Filesystem.folderName(oldPath)
const parentPath = window.qBittorrent.Filesystem.folderName(oldPath);
const newPath = parentPath
? parentPath + window.qBittorrent.Filesystem.PathSeparator + newName
: newName;

View File

@ -1094,6 +1094,14 @@
<input type="text" id="UPnPLeaseDuration" style="width: 15em;" />
</td>
</tr>
<tr>
<td>
<label for="peerToS">QBT_TR(Type of service (ToS) for connections to peers)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#peer_tos" target="_blank">(?)</a></label>
</td>
<td>
<input type="text" id="peerToS" style="width: 15em;" />
</td>
</tr>
<tr>
<td>
<label for="utpTCPMixedModeAlgorithm">QBT_TR(μTP-TCP mixed mode algorithm:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#mixed_mode_algorithm" target="_blank">(?)</a></label>
@ -1920,6 +1928,7 @@
$('outgoingPortsMin').setProperty('value', pref.outgoing_ports_min);
$('outgoingPortsMax').setProperty('value', pref.outgoing_ports_max);
$('UPnPLeaseDuration').setProperty('value', pref.upnp_lease_duration);
$('peerToS').setProperty('value', pref.peer_tos);
$('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);
@ -2308,6 +2317,7 @@
settings.set('outgoing_ports_min', $('outgoingPortsMin').getProperty('value'));
settings.set('outgoing_ports_max', $('outgoingPortsMax').getProperty('value'));
settings.set('upnp_lease_duration', $('UPnPLeaseDuration').getProperty('value'));
settings.set('peer_tos', $('peerToS').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'));