Browse Source

Add `connection_speed` to advanced settings

Now we follow libtorrent current default value 30.
Closes #6973.

Also bump WebAPI version.
adaptive-webui-19844
Chocobo1 4 years ago
parent
commit
ef79546508
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 17
      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. 3
      src/webui/webapplication.cpp
  7. 4
      src/webui/webapplication.h
  8. 10
      src/webui/www/private/views/preferences.html

17
src/base/bittorrent/session.cpp

@ -352,6 +352,7 @@ Session::Session(QObject *parent)
, m_sendBufferWatermark(BITTORRENT_SESSION_KEY("SendBufferWatermark"), 500) , m_sendBufferWatermark(BITTORRENT_SESSION_KEY("SendBufferWatermark"), 500)
, m_sendBufferLowWatermark(BITTORRENT_SESSION_KEY("SendBufferLowWatermark"), 10) , m_sendBufferLowWatermark(BITTORRENT_SESSION_KEY("SendBufferLowWatermark"), 10)
, m_sendBufferWatermarkFactor(BITTORRENT_SESSION_KEY("SendBufferWatermarkFactor"), 50) , m_sendBufferWatermarkFactor(BITTORRENT_SESSION_KEY("SendBufferWatermarkFactor"), 50)
, m_connectionSpeed(BITTORRENT_SESSION_KEY("ConnectionSpeed"), 30)
, m_socketBacklogSize(BITTORRENT_SESSION_KEY("SocketBacklogSize"), 30) , m_socketBacklogSize(BITTORRENT_SESSION_KEY("SocketBacklogSize"), 30)
, m_isAnonymousModeEnabled(BITTORRENT_SESSION_KEY("AnonymousModeEnabled"), false) , m_isAnonymousModeEnabled(BITTORRENT_SESSION_KEY("AnonymousModeEnabled"), false)
, m_isQueueingEnabled(BITTORRENT_SESSION_KEY("QueueingSystemEnabled"), false) , m_isQueueingEnabled(BITTORRENT_SESSION_KEY("QueueingSystemEnabled"), false)
@ -1070,7 +1071,6 @@ void Session::initializeNativeSession()
// Speed up exit // Speed up exit
pack.set_int(lt::settings_pack::auto_scrape_interval, 1200); // 20 minutes pack.set_int(lt::settings_pack::auto_scrape_interval, 1200); // 20 minutes
pack.set_int(lt::settings_pack::auto_scrape_min_interval, 900); // 15 minutes pack.set_int(lt::settings_pack::auto_scrape_min_interval, 900); // 15 minutes
pack.set_int(lt::settings_pack::connection_speed, 20); // default is 10
// libtorrent 1.1 enables UPnP & NAT-PMP by default // libtorrent 1.1 enables UPnP & NAT-PMP by default
// turn them off before `lt::session` ctor to avoid split second effects // turn them off before `lt::session` ctor to avoid split second effects
pack.set_bool(lt::settings_pack::enable_upnp, false); pack.set_bool(lt::settings_pack::enable_upnp, false);
@ -1187,6 +1187,8 @@ void Session::initMetrics()
void Session::loadLTSettings(lt::settings_pack &settingsPack) void Session::loadLTSettings(lt::settings_pack &settingsPack)
{ {
settingsPack.set_int(lt::settings_pack::connection_speed, connectionSpeed());
// from libtorrent doc: // from libtorrent doc:
// It will not take affect until the listen_interfaces settings is updated // It will not take affect until the listen_interfaces settings is updated
settingsPack.set_int(lt::settings_pack::listen_queue_size, socketBacklogSize()); settingsPack.set_int(lt::settings_pack::listen_queue_size, socketBacklogSize());
@ -3324,6 +3326,19 @@ void Session::setSendBufferWatermarkFactor(const int value)
configureDeferred(); configureDeferred();
} }
int Session::connectionSpeed() const
{
return m_connectionSpeed;
}
void Session::setConnectionSpeed(const int value)
{
if (value == m_connectionSpeed) return;
m_connectionSpeed = value;
configureDeferred();
}
int Session::socketBacklogSize() const int Session::socketBacklogSize() const
{ {
return m_socketBacklogSize; return m_socketBacklogSize;

3
src/base/bittorrent/session.h

@ -372,6 +372,8 @@ namespace BitTorrent
void setSendBufferLowWatermark(int value); void setSendBufferLowWatermark(int value);
int sendBufferWatermarkFactor() const; int sendBufferWatermarkFactor() const;
void setSendBufferWatermarkFactor(int value); void setSendBufferWatermarkFactor(int value);
int connectionSpeed() const;
void setConnectionSpeed(int value);
int socketBacklogSize() const; int socketBacklogSize() const;
void setSocketBacklogSize(int value); void setSocketBacklogSize(int value);
bool isAnonymousModeEnabled() const; bool isAnonymousModeEnabled() const;
@ -672,6 +674,7 @@ namespace BitTorrent
CachedSettingValue<int> m_sendBufferWatermark; CachedSettingValue<int> m_sendBufferWatermark;
CachedSettingValue<int> m_sendBufferLowWatermark; CachedSettingValue<int> m_sendBufferLowWatermark;
CachedSettingValue<int> m_sendBufferWatermarkFactor; CachedSettingValue<int> m_sendBufferWatermarkFactor;
CachedSettingValue<int> m_connectionSpeed;
CachedSettingValue<int> m_socketBacklogSize; CachedSettingValue<int> m_socketBacklogSize;
CachedSettingValue<bool> m_isAnonymousModeEnabled; CachedSettingValue<bool> m_isAnonymousModeEnabled;
CachedSettingValue<bool> m_isQueueingEnabled; CachedSettingValue<bool> m_isQueueingEnabled;

9
src/gui/advancedsettings.cpp

@ -115,6 +115,7 @@ namespace
SEND_BUF_LOW_WATERMARK, SEND_BUF_LOW_WATERMARK,
SEND_BUF_WATERMARK_FACTOR, SEND_BUF_WATERMARK_FACTOR,
// networking & ports // networking & ports
CONNECTION_SPEED,
SOCKET_BACKLOG_SIZE, SOCKET_BACKLOG_SIZE,
OUTGOING_PORT_MIN, OUTGOING_PORT_MIN,
OUTGOING_PORT_MAX, OUTGOING_PORT_MAX,
@ -223,6 +224,8 @@ void AdvancedSettings::saveAdvancedSettings()
session->setSendBufferWatermark(m_spinBoxSendBufferWatermark.value()); session->setSendBufferWatermark(m_spinBoxSendBufferWatermark.value());
session->setSendBufferLowWatermark(m_spinBoxSendBufferLowWatermark.value()); session->setSendBufferLowWatermark(m_spinBoxSendBufferLowWatermark.value());
session->setSendBufferWatermarkFactor(m_spinBoxSendBufferWatermarkFactor.value()); session->setSendBufferWatermarkFactor(m_spinBoxSendBufferWatermarkFactor.value());
// Outgoing connections per second
session->setConnectionSpeed(m_spinBoxConnectionSpeed.value());
// Socket listen backlog size // Socket listen backlog size
session->setSocketBacklogSize(m_spinBoxSocketBacklogSize.value()); session->setSocketBacklogSize(m_spinBoxSocketBacklogSize.value());
// Save resume data interval // Save resume data interval
@ -525,6 +528,12 @@ void AdvancedSettings::loadAdvancedSettings()
m_spinBoxSendBufferWatermarkFactor.setValue(session->sendBufferWatermarkFactor()); m_spinBoxSendBufferWatermarkFactor.setValue(session->sendBufferWatermarkFactor());
addRow(SEND_BUF_WATERMARK_FACTOR, (tr("Send buffer watermark factor") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#send_buffer_watermark_factor", "(?)")) addRow(SEND_BUF_WATERMARK_FACTOR, (tr("Send buffer watermark factor") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#send_buffer_watermark_factor", "(?)"))
, &m_spinBoxSendBufferWatermarkFactor); , &m_spinBoxSendBufferWatermarkFactor);
// Outgoing connections per second
m_spinBoxConnectionSpeed.setMinimum(0);
m_spinBoxConnectionSpeed.setMaximum(std::numeric_limits<int>::max());
m_spinBoxConnectionSpeed.setValue(session->connectionSpeed());
addRow(CONNECTION_SPEED, (tr("Outgoing connections per second") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#connection_speed", "(?)"))
, &m_spinBoxConnectionSpeed);
// Socket listen backlog size // Socket listen backlog size
m_spinBoxSocketBacklogSize.setMinimum(1); m_spinBoxSocketBacklogSize.setMinimum(1);
m_spinBoxSocketBacklogSize.setMaximum(std::numeric_limits<int>::max()); m_spinBoxSocketBacklogSize.setMaximum(std::numeric_limits<int>::max());

2
src/gui/advancedsettings.h

@ -63,7 +63,7 @@ private:
QSpinBox m_spinBoxAsyncIOThreads, m_spinBoxFilePoolSize, m_spinBoxCheckingMemUsage, QSpinBox m_spinBoxAsyncIOThreads, m_spinBoxFilePoolSize, m_spinBoxCheckingMemUsage,
m_spinBoxSaveResumeDataInterval, m_spinBoxOutgoingPortsMin, m_spinBoxOutgoingPortsMax, m_spinBoxUPnPLeaseDuration, m_spinBoxPeerToS, 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_spinBoxConnectionSpeed, m_spinBoxSocketBacklogSize, m_spinBoxMaxConcurrentHTTPAnnounces, m_spinBoxStopTrackerTimeout,
m_spinBoxSavePathHistoryLength, m_spinBoxPeerTurnover, m_spinBoxPeerTurnoverCutoff, m_spinBoxPeerTurnoverInterval; m_spinBoxSavePathHistoryLength, m_spinBoxPeerTurnover, m_spinBoxPeerTurnoverCutoff, m_spinBoxPeerTurnoverInterval;
QCheckBox m_checkBoxOsCache, m_checkBoxRecheckCompleted, m_checkBoxResolveCountries, m_checkBoxResolveHosts, QCheckBox m_checkBoxOsCache, m_checkBoxRecheckCompleted, m_checkBoxResolveCountries, m_checkBoxResolveHosts,
m_checkBoxProgramNotifications, m_checkBoxTorrentAddedNotifications, m_checkBoxTrackerFavicon, m_checkBoxTrackerStatus, m_checkBoxProgramNotifications, m_checkBoxTorrentAddedNotifications, m_checkBoxTrackerFavicon, m_checkBoxTrackerStatus,

5
src/webui/api/appcontroller.cpp

@ -302,6 +302,8 @@ void AppController::preferencesAction()
data["send_buffer_watermark"] = session->sendBufferWatermark(); data["send_buffer_watermark"] = session->sendBufferWatermark();
data["send_buffer_low_watermark"] = session->sendBufferLowWatermark(); data["send_buffer_low_watermark"] = session->sendBufferLowWatermark();
data["send_buffer_watermark_factor"] = session->sendBufferWatermarkFactor(); data["send_buffer_watermark_factor"] = session->sendBufferWatermarkFactor();
// Outgoing connections per second
data["connection_speed"] = session->connectionSpeed();
// Socket listen backlog size // Socket listen backlog size
data["socket_backlog_size"] = session->socketBacklogSize(); data["socket_backlog_size"] = session->socketBacklogSize();
// Outgoing ports // Outgoing ports
@ -754,6 +756,9 @@ void AppController::setPreferencesAction()
session->setSendBufferLowWatermark(it.value().toInt()); session->setSendBufferLowWatermark(it.value().toInt());
if (hasKey("send_buffer_watermark_factor")) if (hasKey("send_buffer_watermark_factor"))
session->setSendBufferWatermarkFactor(it.value().toInt()); session->setSendBufferWatermarkFactor(it.value().toInt());
// Outgoing connections per second
if (hasKey("connection_speed"))
session->setConnectionSpeed(it.value().toInt());
// Socket listen backlog size // Socket listen backlog size
if (hasKey("socket_backlog_size")) if (hasKey("socket_backlog_size"))
session->setSocketBacklogSize(it.value().toInt()); session->setSocketBacklogSize(it.value().toInt());

3
src/webui/webapplication.cpp

@ -62,7 +62,8 @@
#include "api/torrentscontroller.h" #include "api/torrentscontroller.h"
#include "api/transfercontroller.h" #include "api/transfercontroller.h"
constexpr int MAX_ALLOWED_FILESIZE = 10 * 1024 * 1024; const int MAX_ALLOWED_FILESIZE = 10 * 1024 * 1024;
const char C_SID[] = "SID"; // name of session id cookie
const QString PATH_PREFIX_ICONS {QStringLiteral("/icons/")}; const QString PATH_PREFIX_ICONS {QStringLiteral("/icons/")};
const QString WWW_FOLDER {QStringLiteral(":/www")}; const QString WWW_FOLDER {QStringLiteral(":/www")};

4
src/webui/webapplication.h

@ -43,13 +43,11 @@
#include "base/utils/net.h" #include "base/utils/net.h"
#include "base/utils/version.h" #include "base/utils/version.h"
constexpr Utils::Version<int, 3, 2> API_VERSION {2, 8, 2}; inline const Utils::Version<int, 3, 2> API_VERSION {2, 8, 3};
class APIController; class APIController;
class WebApplication; class WebApplication;
constexpr char C_SID[] = "SID"; // name of session id cookie
class WebSession final : public ISession class WebSession final : public ISession
{ {
public: public:

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

@ -1047,6 +1047,14 @@
<input type="text" id="sendBufferWatermarkFactor" style="width: 15em;" />&nbsp;&nbsp;% <input type="text" id="sendBufferWatermarkFactor" style="width: 15em;" />&nbsp;&nbsp;%
</td> </td>
</tr> </tr>
<tr>
<td>
<label for="connectionSpeed">QBT_TR(Outgoing connections per second:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#connection_speed" target="_blank">(?)</a></label>
</td>
<td>
<input type="text" id="connectionSpeed" style="width: 15em;" />
</td>
</tr>
<tr> <tr>
<td> <td>
<label for="socketBacklogSize">QBT_TR(Socket backlog size:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#listen_queue_size" target="_blank">(?)</a></label> <label for="socketBacklogSize">QBT_TR(Socket backlog size:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#listen_queue_size" target="_blank">(?)</a></label>
@ -1896,6 +1904,7 @@
$('sendBufferWatermark').setProperty('value', pref.send_buffer_watermark); $('sendBufferWatermark').setProperty('value', pref.send_buffer_watermark);
$('sendBufferLowWatermark').setProperty('value', pref.send_buffer_low_watermark); $('sendBufferLowWatermark').setProperty('value', pref.send_buffer_low_watermark);
$('sendBufferWatermarkFactor').setProperty('value', pref.send_buffer_watermark_factor); $('sendBufferWatermarkFactor').setProperty('value', pref.send_buffer_watermark_factor);
$('connectionSpeed').setProperty('value', pref.connection_speed);
$('socketBacklogSize').setProperty('value', pref.socket_backlog_size); $('socketBacklogSize').setProperty('value', pref.socket_backlog_size);
$('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);
@ -2285,6 +2294,7 @@
settings.set('send_buffer_watermark', $('sendBufferWatermark').getProperty('value')); settings.set('send_buffer_watermark', $('sendBufferWatermark').getProperty('value'));
settings.set('send_buffer_low_watermark', $('sendBufferLowWatermark').getProperty('value')); settings.set('send_buffer_low_watermark', $('sendBufferLowWatermark').getProperty('value'));
settings.set('send_buffer_watermark_factor', $('sendBufferWatermarkFactor').getProperty('value')); settings.set('send_buffer_watermark_factor', $('sendBufferWatermarkFactor').getProperty('value'));
settings.set('connection_speed', $('connectionSpeed').getProperty('value'));
settings.set('socket_backlog_size', $('socketBacklogSize').getProperty('value')); settings.set('socket_backlog_size', $('socketBacklogSize').getProperty('value'));
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'));

Loading…
Cancel
Save