Expose 'DHT bootstrap nodes' setting

This allows user to select DHT bootstrap nodes. Or even use their own bootstrap nodes.

PR #19594.
This commit is contained in:
Chocobo1 2023-09-14 13:57:34 +08:00 committed by GitHub
parent 633167a6da
commit dcba9eda00
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 49 additions and 4 deletions

View file

@ -117,6 +117,7 @@ namespace
{
const char PEER_ID[] = "qB";
const auto USER_AGENT = QStringLiteral("qBittorrent/" QBT_VERSION_2);
const QString DEFAULT_DHT_BOOTSTRAP_NODES = u"dht.libtorrent.org:25401, dht.transmissionbt.com:6881, router.bittorrent.com:6881, router.utorrent.com:6881, dht.aelitis.com:6881"_s;
void torrentQueuePositionUp(const lt::torrent_handle &handle)
{
@ -378,6 +379,7 @@ QStringList Session::expandCategory(const QString &category)
SessionImpl::SessionImpl(QObject *parent)
: Session(parent)
, m_DHTBootstrapNodes(BITTORRENT_SESSION_KEY(u"DHTBootstrapNodes"_s), DEFAULT_DHT_BOOTSTRAP_NODES)
, m_isDHTEnabled(BITTORRENT_SESSION_KEY(u"DHTEnabled"_s), true)
, m_isLSDEnabled(BITTORRENT_SESSION_KEY(u"LSDEnabled"_s), true)
, m_isPeXEnabled(BITTORRENT_SESSION_KEY(u"PeXEnabled"_s), true)
@ -603,6 +605,21 @@ SessionImpl::~SessionImpl()
delete m_nativeSession;
}
QString SessionImpl::getDHTBootstrapNodes() const
{
const QString nodes = m_DHTBootstrapNodes;
return !nodes.isEmpty() ? nodes : DEFAULT_DHT_BOOTSTRAP_NODES;
}
void SessionImpl::setDHTBootstrapNodes(const QString &nodes)
{
if (nodes == m_DHTBootstrapNodes)
return;
m_DHTBootstrapNodes = nodes;
configureDeferred();
}
bool SessionImpl::isDHTEnabled() const
{
return m_isDHTEnabled;
@ -1885,9 +1902,8 @@ lt::settings_pack SessionImpl::loadLTSettings() const
settingsPack.set_bool(lt::settings_pack::apply_ip_filter_to_trackers, isTrackerFilteringEnabled());
settingsPack.set_str(lt::settings_pack::dht_bootstrap_nodes, getDHTBootstrapNodes().toStdString());
settingsPack.set_bool(lt::settings_pack::enable_dht, isDHTEnabled());
if (isDHTEnabled())
settingsPack.set_str(lt::settings_pack::dht_bootstrap_nodes, "dht.libtorrent.org:25401,router.bittorrent.com:6881,router.utorrent.com:6881,dht.transmissionbt.com:6881,dht.aelitis.com:6881");
settingsPack.set_bool(lt::settings_pack::enable_lsd, isLSDEnabled());
switch (chokingAlgorithm())