Browse Source

Merge pull request #14493 from Chocobo1/tos

Expose ToS setting from libtorrent
adaptive-webui-19844
Mike Tzou 4 years ago committed by GitHub
parent
commit
f3435c5e35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      src/base/bittorrent/session.cpp
  2. 3
      src/base/bittorrent/session.h
  3. 9
      src/gui/advancedsettings.cpp
  4. 2
      src/gui/advancedsettings.h
  5. 5
      src/webui/api/appcontroller.cpp
  6. 2
      src/webui/www/private/rename_file.html
  7. 10
      src/webui/www/private/views/preferences.html

20
src/base/bittorrent/session.cpp

@ -372,6 +372,7 @@ Session::Session(QObject *parent) @@ -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) @@ -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) @@ -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;

3
src/base/bittorrent/session.h

@ -384,6 +384,8 @@ namespace BitTorrent @@ -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 @@ -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;

9
src/gui/advancedsettings.cpp

@ -115,6 +115,7 @@ namespace @@ -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() @@ -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() @@ -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()));

2
src/gui/advancedsettings.h

@ -61,7 +61,7 @@ private: @@ -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;

5
src/webui/api/appcontroller.cpp

@ -309,6 +309,8 @@ void AppController::preferencesAction() @@ -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() @@ -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()));

2
src/webui/www/private/rename_file.html

@ -58,7 +58,7 @@ @@ -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;

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

@ -1094,6 +1094,14 @@ @@ -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 @@ @@ -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 @@ @@ -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'));

Loading…
Cancel
Save