Browse Source

Make I2P session options configurable

PR #19079.
Closes #18980.
adaptive-webui-19844
Vort 1 year ago committed by GitHub
parent
commit
ff5d02bcf2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      src/base/bittorrent/session.h
  2. 68
      src/base/bittorrent/sessionimpl.cpp
  3. 12
      src/base/bittorrent/sessionimpl.h
  4. 35
      src/gui/advancedsettings.cpp
  5. 3
      src/gui/advancedsettings.h

8
src/base/bittorrent/session.h

@ -271,6 +271,14 @@ namespace BitTorrent
virtual void setI2PPort(int port) = 0; virtual void setI2PPort(int port) = 0;
virtual bool I2PMixedMode() const = 0; virtual bool I2PMixedMode() const = 0;
virtual void setI2PMixedMode(bool enabled) = 0; virtual void setI2PMixedMode(bool enabled) = 0;
virtual int I2PInboundQuantity() const = 0;
virtual void setI2PInboundQuantity(int value) = 0;
virtual int I2POutboundQuantity() const = 0;
virtual void setI2POutboundQuantity(int value) = 0;
virtual int I2PInboundLength() const = 0;
virtual void setI2PInboundLength(int value) = 0;
virtual int I2POutboundLength() const = 0;
virtual void setI2POutboundLength(int value) = 0;
virtual bool isProxyPeerConnectionsEnabled() const = 0; virtual bool isProxyPeerConnectionsEnabled() const = 0;
virtual void setProxyPeerConnectionsEnabled(bool enabled) = 0; virtual void setProxyPeerConnectionsEnabled(bool enabled) = 0;
virtual ChokingAlgorithm chokingAlgorithm() const = 0; virtual ChokingAlgorithm chokingAlgorithm() const = 0;

68
src/base/bittorrent/sessionimpl.cpp

@ -528,6 +528,10 @@ SessionImpl::SessionImpl(QObject *parent)
, m_I2PAddress {BITTORRENT_SESSION_KEY(u"I2P/Address"_qs), u"127.0.0.1"_qs} , m_I2PAddress {BITTORRENT_SESSION_KEY(u"I2P/Address"_qs), u"127.0.0.1"_qs}
, m_I2PPort {BITTORRENT_SESSION_KEY(u"I2P/Port"_qs), 7656} , m_I2PPort {BITTORRENT_SESSION_KEY(u"I2P/Port"_qs), 7656}
, m_I2PMixedMode {BITTORRENT_SESSION_KEY(u"I2P/MixedMode"_qs), false} , m_I2PMixedMode {BITTORRENT_SESSION_KEY(u"I2P/MixedMode"_qs), false}
, m_I2PInboundQuantity {BITTORRENT_SESSION_KEY(u"I2P/InboundQuantity"_qs), 3}
, m_I2POutboundQuantity {BITTORRENT_SESSION_KEY(u"I2P/OutboundQuantity"_qs), 3}
, m_I2PInboundLength {BITTORRENT_SESSION_KEY(u"I2P/InboundLength"_qs), 3}
, m_I2POutboundLength {BITTORRENT_SESSION_KEY(u"I2P/OutboundLength"_qs), 3}
, m_seedingLimitTimer {new QTimer(this)} , m_seedingLimitTimer {new QTimer(this)}
, m_resumeDataTimer {new QTimer(this)} , m_resumeDataTimer {new QTimer(this)}
, m_ioThread {new QThread} , m_ioThread {new QThread}
@ -1678,6 +1682,14 @@ lt::settings_pack SessionImpl::loadLTSettings() const
settingsPack.set_bool(lt::settings_pack::allow_i2p_mixed, false); settingsPack.set_bool(lt::settings_pack::allow_i2p_mixed, false);
} }
#ifdef QBT_USES_LIBTORRENT2
// I2P session options
settingsPack.set_int(lt::settings_pack::i2p_inbound_quantity, I2PInboundQuantity());
settingsPack.set_int(lt::settings_pack::i2p_outbound_quantity, I2POutboundQuantity());
settingsPack.set_int(lt::settings_pack::i2p_inbound_length, I2PInboundLength());
settingsPack.set_int(lt::settings_pack::i2p_outbound_length, I2POutboundLength());
#endif
// proxy // proxy
settingsPack.set_int(lt::settings_pack::proxy_type, lt::settings_pack::none); settingsPack.set_int(lt::settings_pack::proxy_type, lt::settings_pack::none);
if (Preferences::instance()->useProxyForBT()) if (Preferences::instance()->useProxyForBT())
@ -3640,6 +3652,62 @@ void SessionImpl::setI2PMixedMode(const bool enabled)
} }
} }
int SessionImpl::I2PInboundQuantity() const
{
return m_I2PInboundQuantity;
}
void SessionImpl::setI2PInboundQuantity(const int value)
{
if (value == m_I2PInboundQuantity)
return;
m_I2PInboundQuantity = value;
configureDeferred();
}
int SessionImpl::I2POutboundQuantity() const
{
return m_I2POutboundQuantity;
}
void SessionImpl::setI2POutboundQuantity(const int value)
{
if (value == m_I2POutboundQuantity)
return;
m_I2POutboundQuantity = value;
configureDeferred();
}
int SessionImpl::I2PInboundLength() const
{
return m_I2PInboundLength;
}
void SessionImpl::setI2PInboundLength(const int value)
{
if (value == m_I2PInboundLength)
return;
m_I2PInboundLength = value;
configureDeferred();
}
int SessionImpl::I2POutboundLength() const
{
return m_I2POutboundLength;
}
void SessionImpl::setI2POutboundLength(const int value)
{
if (value == m_I2POutboundLength)
return;
m_I2POutboundLength = value;
configureDeferred();
}
bool SessionImpl::isProxyPeerConnectionsEnabled() const bool SessionImpl::isProxyPeerConnectionsEnabled() const
{ {
return m_isProxyPeerConnectionsEnabled; return m_isProxyPeerConnectionsEnabled;

12
src/base/bittorrent/sessionimpl.h

@ -250,6 +250,14 @@ namespace BitTorrent
void setI2PPort(int port) override; void setI2PPort(int port) override;
bool I2PMixedMode() const override; bool I2PMixedMode() const override;
void setI2PMixedMode(bool enabled) override; void setI2PMixedMode(bool enabled) override;
int I2PInboundQuantity() const override;
void setI2PInboundQuantity(int value) override;
int I2POutboundQuantity() const override;
void setI2POutboundQuantity(int value) override;
int I2PInboundLength() const override;
void setI2PInboundLength(int value) override;
int I2POutboundLength() const override;
void setI2POutboundLength(int value) override;
bool isProxyPeerConnectionsEnabled() const override; bool isProxyPeerConnectionsEnabled() const override;
void setProxyPeerConnectionsEnabled(bool enabled) override; void setProxyPeerConnectionsEnabled(bool enabled) override;
ChokingAlgorithm chokingAlgorithm() const override; ChokingAlgorithm chokingAlgorithm() const override;
@ -699,6 +707,10 @@ namespace BitTorrent
CachedSettingValue<QString> m_I2PAddress; CachedSettingValue<QString> m_I2PAddress;
CachedSettingValue<int> m_I2PPort; CachedSettingValue<int> m_I2PPort;
CachedSettingValue<bool> m_I2PMixedMode; CachedSettingValue<bool> m_I2PMixedMode;
CachedSettingValue<int> m_I2PInboundQuantity;
CachedSettingValue<int> m_I2POutboundQuantity;
CachedSettingValue<int> m_I2PInboundLength;
CachedSettingValue<int> m_I2POutboundLength;
bool m_isRestored = false; bool m_isRestored = false;

35
src/gui/advancedsettings.cpp

@ -153,6 +153,12 @@ namespace
PEER_TURNOVER_CUTOFF, PEER_TURNOVER_CUTOFF,
PEER_TURNOVER_INTERVAL, PEER_TURNOVER_INTERVAL,
REQUEST_QUEUE_SIZE, REQUEST_QUEUE_SIZE,
#ifdef QBT_USES_LIBTORRENT2
I2P_INBOUND_QUANTITY,
I2P_OUTBOUND_QUANTITY,
I2P_INBOUND_LENGTH,
I2P_OUTBOUND_LENGTH,
#endif
ROW_COUNT ROW_COUNT
}; };
@ -319,6 +325,13 @@ void AdvancedSettings::saveAdvancedSettings() const
session->setPeerTurnoverInterval(m_spinBoxPeerTurnoverInterval.value()); session->setPeerTurnoverInterval(m_spinBoxPeerTurnoverInterval.value());
// Maximum outstanding requests to a single peer // Maximum outstanding requests to a single peer
session->setRequestQueueSize(m_spinBoxRequestQueueSize.value()); session->setRequestQueueSize(m_spinBoxRequestQueueSize.value());
#ifdef QBT_USES_LIBTORRENT2
// I2P session options
session->setI2PInboundQuantity(m_spinBoxI2PInboundQuantity.value());
session->setI2POutboundQuantity(m_spinBoxI2POutboundQuantity.value());
session->setI2PInboundLength(m_spinBoxI2PInboundLength.value());
session->setI2POutboundLength(m_spinBoxI2POutboundLength.value());
#endif
} }
#ifndef QBT_USES_LIBTORRENT2 #ifndef QBT_USES_LIBTORRENT2
@ -826,6 +839,28 @@ void AdvancedSettings::loadAdvancedSettings()
m_spinBoxRequestQueueSize.setValue(session->requestQueueSize()); m_spinBoxRequestQueueSize.setValue(session->requestQueueSize());
addRow(REQUEST_QUEUE_SIZE, (tr("Maximum outstanding requests to a single peer") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#max_out_request_queue", u"(?)")) addRow(REQUEST_QUEUE_SIZE, (tr("Maximum outstanding requests to a single peer") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#max_out_request_queue", u"(?)"))
, &m_spinBoxRequestQueueSize); , &m_spinBoxRequestQueueSize);
#ifdef QBT_USES_LIBTORRENT2
m_spinBoxI2PInboundQuantity.setMinimum(1);
m_spinBoxI2PInboundQuantity.setMaximum(16);
m_spinBoxI2PInboundQuantity.setValue(session->I2PInboundQuantity());
addRow(I2P_INBOUND_QUANTITY, (tr("I2P inbound quantity") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#i2p_inbound_quantity", u"(?)"))
, &m_spinBoxI2PInboundQuantity);
m_spinBoxI2POutboundQuantity.setMinimum(1);
m_spinBoxI2POutboundQuantity.setMaximum(16);
m_spinBoxI2POutboundQuantity.setValue(session->I2POutboundQuantity());
addRow(I2P_OUTBOUND_QUANTITY, (tr("I2P outbound quantity") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#i2p_outbound_quantity", u"(?)"))
, &m_spinBoxI2POutboundQuantity);
m_spinBoxI2PInboundLength.setMinimum(0);
m_spinBoxI2PInboundLength.setMaximum(7);
m_spinBoxI2PInboundLength.setValue(session->I2PInboundLength());
addRow(I2P_INBOUND_LENGTH, (tr("I2P inbound length") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#i2p_inbound_length", u"(?)"))
, &m_spinBoxI2PInboundLength);
m_spinBoxI2POutboundLength.setMinimum(0);
m_spinBoxI2POutboundLength.setMaximum(7);
m_spinBoxI2POutboundLength.setValue(session->I2POutboundLength());
addRow(I2P_OUTBOUND_LENGTH, (tr("I2P outbound length") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#i2p_outbound_length", u"(?)"))
, &m_spinBoxI2POutboundLength);
#endif
} }
template <typename T> template <typename T>

3
src/gui/advancedsettings.h

@ -85,7 +85,8 @@ private:
QCheckBox m_checkBoxCoalesceRW; QCheckBox m_checkBoxCoalesceRW;
#else #else
QComboBox m_comboBoxDiskIOType; QComboBox m_comboBoxDiskIOType;
QSpinBox m_spinBoxMemoryWorkingSetLimit, m_spinBoxHashingThreads; QSpinBox m_spinBoxMemoryWorkingSetLimit, m_spinBoxHashingThreads,
m_spinBoxI2PInboundQuantity, m_spinBoxI2POutboundQuantity, m_spinBoxI2PInboundLength, m_spinBoxI2POutboundLength;
#endif #endif
// OS dependent settings // OS dependent settings

Loading…
Cancel
Save