Migrate away from old libtorrent setting

The setting has been renamed from `peer_tos` to `peer_dscp` and the default value has changed
from `0x04` to `0x01`.
Note that in WebAPI and qbt config, the previous name is retained to avoid disruption to user.

Upstream PR:
https://github.com/arvidn/libtorrent/pull/6822
https://github.com/arvidn/libtorrent/pull/8072

PR #23669.
This commit is contained in:
Chocobo1
2025-12-30 21:17:37 +08:00
committed by GitHub
parent 52a6e7229b
commit 351b065553
7 changed files with 29 additions and 29 deletions

View File

@@ -461,7 +461,7 @@ void AppController::preferencesAction()
// UPnP lease duration
data[u"upnp_lease_duration"_s] = session->UPnPLeaseDuration();
// Type of service
data[u"peer_tos"_s] = session->peerToS();
data[u"peer_tos"_s] = session->peerDSCP();
// uTP-TCP mixed mode
data[u"utp_tcp_mixed_mode"_s] = static_cast<int>(session->utpMixedMode());
// Hostname resolver cache TTL
@@ -1114,7 +1114,7 @@ void AppController::setPreferencesAction()
session->setUPnPLeaseDuration(it.value().toInt());
// Type of service
if (hasKey(u"peer_tos"_s))
session->setPeerToS(it.value().toInt());
session->setPeerDSCP(it.value().toInt());
// uTP-TCP mixed mode
if (hasKey(u"utp_tcp_mixed_mode"_s))
session->setUtpMixedMode(static_cast<BitTorrent::MixedModeAlgorithm>(it.value().toInt()));

View File

@@ -1561,10 +1561,10 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
</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>
<label for="peerDSCP">QBT_TR(Differentiated Services Code Point (DSCP) for connections to peers)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#peer_dscp" target="_blank">(?)</a></label>
</td>
<td>
<input type="text" id="peerToS" style="width: 15em;">
<input type="text" id="peerDSCP" style="width: 15em;">
</td>
</tr>
<tr>
@@ -2668,7 +2668,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
document.getElementById("outgoingPortsMin").value = pref.outgoing_ports_min;
document.getElementById("outgoingPortsMax").value = pref.outgoing_ports_max;
document.getElementById("UPnPLeaseDuration").value = pref.upnp_lease_duration;
document.getElementById("peerToS").value = pref.peer_tos;
document.getElementById("peerDSCP").value = pref.peer_tos;
document.getElementById("utpTCPMixedModeAlgorithm").value = pref.utp_tcp_mixed_mode;
document.getElementById("hostnameCacheTTL").value = pref.hostname_cache_ttl;
document.getElementById("IDNSupportCheckbox").checked = pref.idn_support_enabled;
@@ -3156,12 +3156,12 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
settings["outgoing_ports_max"] = Number(document.getElementById("outgoingPortsMax").value);
settings["upnp_lease_duration"] = Number(document.getElementById("UPnPLeaseDuration").value);
const peerToS = Number(document.getElementById("peerToS").value);
if (Number.isNaN(peerToS) || (peerToS < 0) || (peerToS > 255)) {
alert("QBT_TR(Peer ToS must be between 0 and 255.)QBT_TR[CONTEXT=HttpServer]");
const peerDSCP = Number(document.getElementById("peerDSCP").value);
if (Number.isNaN(peerDSCP) || (peerDSCP < 0) || (peerDSCP > 255)) {
alert("QBT_TR(Peer DSCP must be between 0 and 255.)QBT_TR[CONTEXT=HttpServer]");
return;
}
settings["peer_tos"] = peerToS;
settings["peer_tos"] = peerDSCP;
settings["utp_tcp_mixed_mode"] = Number(document.getElementById("utpTCPMixedModeAlgorithm").value);
settings["hostname_cache_ttl"] = Number(document.getElementById("hostnameCacheTTL").value);