Browse Source

Expose ToS setting from libtorrent

Closes #14420.
adaptive-webui-19844
Chocobo1 4 years ago
parent
commit
5161758193
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  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. 10
      src/webui/www/private/views/preferences.html

20
src/base/bittorrent/session.cpp

@ -372,6 +372,7 @@ Session::Session(QObject *parent)
, m_outgoingPortsMin(BITTORRENT_SESSION_KEY("OutgoingPortsMin"), 0) , m_outgoingPortsMin(BITTORRENT_SESSION_KEY("OutgoingPortsMin"), 0)
, m_outgoingPortsMax(BITTORRENT_SESSION_KEY("OutgoingPortsMax"), 0) , m_outgoingPortsMax(BITTORRENT_SESSION_KEY("OutgoingPortsMax"), 0)
, m_UPnPLeaseDuration(BITTORRENT_SESSION_KEY("UPnPLeaseDuration"), 0) , m_UPnPLeaseDuration(BITTORRENT_SESSION_KEY("UPnPLeaseDuration"), 0)
, m_peerToS(BITTORRENT_SESSION_KEY("PeerToS"), 0x20)
, m_ignoreLimitsOnLAN(BITTORRENT_SESSION_KEY("IgnoreLimitsOnLAN"), false) , m_ignoreLimitsOnLAN(BITTORRENT_SESSION_KEY("IgnoreLimitsOnLAN"), false)
, m_includeOverheadInLimits(BITTORRENT_SESSION_KEY("IncludeOverheadInLimits"), false) , m_includeOverheadInLimits(BITTORRENT_SESSION_KEY("IncludeOverheadInLimits"), false)
, m_announceIP(BITTORRENT_SESSION_KEY("AnnounceIP")) , m_announceIP(BITTORRENT_SESSION_KEY("AnnounceIP"))
@ -1335,9 +1336,10 @@ void Session::loadLTSettings(lt::settings_pack &settingsPack)
// Outgoing ports // Outgoing ports
settingsPack.set_int(lt::settings_pack::outgoing_port, outgoingPortsMin()); settingsPack.set_int(lt::settings_pack::outgoing_port, outgoingPortsMin());
settingsPack.set_int(lt::settings_pack::num_outgoing_ports, outgoingPortsMax() - outgoingPortsMin() + 1); 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()); 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 // Include overhead in transfer limits
settingsPack.set_bool(lt::settings_pack::rate_limit_ip_overhead, includeOverheadInLimits()); settingsPack.set_bool(lt::settings_pack::rate_limit_ip_overhead, includeOverheadInLimits());
// IP address to announce to trackers // 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 bool Session::ignoreLimitsOnLAN() const
{ {
return m_ignoreLimitsOnLAN; return m_ignoreLimitsOnLAN;

3
src/base/bittorrent/session.h

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

9
src/gui/advancedsettings.cpp

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

2
src/gui/advancedsettings.h

@ -61,7 +61,7 @@ private:
template <typename T> void addRow(int row, const QString &text, T *widget); template <typename T> void addRow(int row, const QString &text, T *widget);
QSpinBox m_spinBoxAsyncIOThreads, m_spinBoxFilePoolSize, m_spinBoxCheckingMemUsage, 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_spinBoxListRefresh, m_spinBoxTrackerPort, m_spinBoxSendBufferWatermark, m_spinBoxSendBufferLowWatermark,
m_spinBoxSendBufferWatermarkFactor, m_spinBoxSocketBacklogSize, m_spinBoxMaxConcurrentHTTPAnnounces, m_spinBoxStopTrackerTimeout, m_spinBoxSendBufferWatermarkFactor, m_spinBoxSocketBacklogSize, m_spinBoxMaxConcurrentHTTPAnnounces, m_spinBoxStopTrackerTimeout,
m_spinBoxSavePathHistoryLength, m_spinBoxPeerTurnover, m_spinBoxPeerTurnoverCutoff, m_spinBoxPeerTurnoverInterval; m_spinBoxSavePathHistoryLength, m_spinBoxPeerTurnover, m_spinBoxPeerTurnoverCutoff, m_spinBoxPeerTurnoverInterval;

5
src/webui/api/appcontroller.cpp

@ -309,6 +309,8 @@ void AppController::preferencesAction()
data["outgoing_ports_max"] = session->outgoingPortsMax(); data["outgoing_ports_max"] = session->outgoingPortsMax();
// UPnP lease duration // UPnP lease duration
data["upnp_lease_duration"] = session->UPnPLeaseDuration(); data["upnp_lease_duration"] = session->UPnPLeaseDuration();
// Type of service
data["peer_tos"] = session->peerToS();
// 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) // Support internationalized domain name (IDN)
@ -772,6 +774,9 @@ void AppController::setPreferencesAction()
// UPnP lease duration // UPnP lease duration
if (hasKey("upnp_lease_duration")) if (hasKey("upnp_lease_duration"))
session->setUPnPLeaseDuration(it.value().toInt()); session->setUPnPLeaseDuration(it.value().toInt());
// Type of service
if (hasKey("peer_tos"))
session->setPeerToS(it.value().toInt());
// 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()));

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

@ -1094,6 +1094,14 @@
<input type="text" id="UPnPLeaseDuration" style="width: 15em;" /> <input type="text" id="UPnPLeaseDuration" style="width: 15em;" />
</td> </td>
</tr> </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> <tr>
<td> <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> <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); $('outgoingPortsMin').setProperty('value', pref.outgoing_ports_min);
$('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);
$('peerToS').setProperty('value', pref.peer_tos);
$('utpTCPMixedModeAlgorithm').setProperty('value', pref.utp_tcp_mixed_mode); $('utpTCPMixedModeAlgorithm').setProperty('value', pref.utp_tcp_mixed_mode);
$('IDNSupportCheckbox').setProperty('checked', pref.idn_support_enabled); $('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);
@ -2308,6 +2317,7 @@
settings.set('outgoing_ports_min', $('outgoingPortsMin').getProperty('value')); settings.set('outgoing_ports_min', $('outgoingPortsMin').getProperty('value'));
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('peer_tos', $('peerToS').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('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'));

Loading…
Cancel
Save