mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 07:18:08 +00:00
parent
015780fc72
commit
2e8e2b04a1
@ -372,6 +372,7 @@ Session::Session(QObject *parent)
|
||||
, m_includeOverheadInLimits(BITTORRENT_SESSION_KEY("IncludeOverheadInLimits"), false)
|
||||
, m_announceIP(BITTORRENT_SESSION_KEY("AnnounceIP"))
|
||||
, m_maxConcurrentHTTPAnnounces(BITTORRENT_SESSION_KEY("MaxConcurrentHTTPAnnounces"), 50)
|
||||
, m_isReannounceWhenAddressChangedEnabled(BITTORRENT_SESSION_KEY("ReannounceWhenAddressChanged"), false)
|
||||
, m_stopTrackerTimeout(BITTORRENT_SESSION_KEY("StopTrackerTimeout"), 5)
|
||||
, m_maxConnections(BITTORRENT_SESSION_KEY("MaxConnections"), 500, lowerLimited(0, -1))
|
||||
, m_maxUploads(BITTORRENT_SESSION_KEY("MaxUploads"), 20, lowerLimited(0, -1))
|
||||
@ -2743,6 +2744,9 @@ void Session::setPort(const int port)
|
||||
{
|
||||
m_port = port;
|
||||
configureListeningInterface();
|
||||
|
||||
if (isReannounceWhenAddressChangedEnabled())
|
||||
reannounceToAllTrackers();
|
||||
}
|
||||
}
|
||||
|
||||
@ -3033,7 +3037,6 @@ void Session::setMaxConnectionsPerTorrent(int max)
|
||||
// Apply this to all session torrents
|
||||
for (const lt::torrent_handle &handle : m_nativeSession->get_torrents())
|
||||
{
|
||||
if (!handle.is_valid()) continue;
|
||||
try
|
||||
{
|
||||
handle.set_max_connections(max);
|
||||
@ -3058,7 +3061,6 @@ void Session::setMaxUploadsPerTorrent(int max)
|
||||
// Apply this to all session torrents
|
||||
for (const lt::torrent_handle &handle : m_nativeSession->get_torrents())
|
||||
{
|
||||
if (!handle.is_valid()) continue;
|
||||
try
|
||||
{
|
||||
handle.set_max_uploads(max);
|
||||
@ -3589,6 +3591,25 @@ void Session::setMaxConcurrentHTTPAnnounces(const int value)
|
||||
configureDeferred();
|
||||
}
|
||||
|
||||
bool Session::isReannounceWhenAddressChangedEnabled() const
|
||||
{
|
||||
return m_isReannounceWhenAddressChangedEnabled;
|
||||
}
|
||||
|
||||
void Session::setReannounceWhenAddressChangedEnabled(const bool enabled)
|
||||
{
|
||||
if (enabled == m_isReannounceWhenAddressChangedEnabled)
|
||||
return;
|
||||
|
||||
m_isReannounceWhenAddressChangedEnabled = enabled;
|
||||
}
|
||||
|
||||
void Session::reannounceToAllTrackers() const
|
||||
{
|
||||
for (const lt::torrent_handle &torrent : m_nativeSession->get_torrents())
|
||||
torrent.force_reannounce(0, -1, lt::torrent_handle::ignore_min_interval);
|
||||
}
|
||||
|
||||
int Session::stopTrackerTimeout() const
|
||||
{
|
||||
return m_stopTrackerTimeout;
|
||||
@ -4636,8 +4657,7 @@ void Session::handleListenSucceededAlert(const lt::listen_succeeded_alert *p)
|
||||
.arg(toString(p->address), proto, QString::number(p->port)), Log::INFO);
|
||||
|
||||
// Force reannounce on all torrents because some trackers blacklist some ports
|
||||
for (const lt::torrent_handle &torrent : m_nativeSession->get_torrents())
|
||||
torrent.force_reannounce();
|
||||
reannounceToAllTrackers();
|
||||
}
|
||||
|
||||
void Session::handleListenFailedAlert(const lt::listen_failed_alert *p)
|
||||
@ -4651,8 +4671,16 @@ void Session::handleListenFailedAlert(const lt::listen_failed_alert *p)
|
||||
|
||||
void Session::handleExternalIPAlert(const lt::external_ip_alert *p)
|
||||
{
|
||||
const QString externalIP {toString(p->external_address)};
|
||||
LogMsg(tr("Detected external IP: %1", "e.g. Detected external IP: 1.1.1.1")
|
||||
.arg(toString(p->external_address)), Log::INFO);
|
||||
.arg(externalIP), Log::INFO);
|
||||
|
||||
if (m_lastExternalIP != externalIP)
|
||||
{
|
||||
if (isReannounceWhenAddressChangedEnabled() && !m_lastExternalIP.isEmpty())
|
||||
reannounceToAllTrackers();
|
||||
m_lastExternalIP = externalIP;
|
||||
}
|
||||
}
|
||||
|
||||
void Session::handleSessionStatsAlert(const lt::session_stats_alert *p)
|
||||
|
@ -402,6 +402,9 @@ namespace BitTorrent
|
||||
void setAnnounceIP(const QString &ip);
|
||||
int maxConcurrentHTTPAnnounces() const;
|
||||
void setMaxConcurrentHTTPAnnounces(int value);
|
||||
bool isReannounceWhenAddressChangedEnabled() const;
|
||||
void setReannounceWhenAddressChangedEnabled(bool enabled);
|
||||
void reannounceToAllTrackers() const;
|
||||
int stopTrackerTimeout() const;
|
||||
void setStopTrackerTimeout(int value);
|
||||
int maxConnections() const;
|
||||
@ -690,6 +693,7 @@ namespace BitTorrent
|
||||
CachedSettingValue<bool> m_includeOverheadInLimits;
|
||||
CachedSettingValue<QString> m_announceIP;
|
||||
CachedSettingValue<int> m_maxConcurrentHTTPAnnounces;
|
||||
CachedSettingValue<bool> m_isReannounceWhenAddressChangedEnabled;
|
||||
CachedSettingValue<int> m_stopTrackerTimeout;
|
||||
CachedSettingValue<int> m_maxConnections;
|
||||
CachedSettingValue<int> m_maxUploads;
|
||||
@ -798,6 +802,8 @@ namespace BitTorrent
|
||||
|
||||
QList<MoveStorageJob> m_moveStorageQueue;
|
||||
|
||||
QString m_lastExternalIP;
|
||||
|
||||
static Session *m_instance;
|
||||
};
|
||||
}
|
||||
|
@ -83,6 +83,7 @@ namespace
|
||||
NOTIFICATION_TIMEOUT,
|
||||
#endif
|
||||
CONFIRM_REMOVE_ALL_TAGS,
|
||||
REANNOUNCE_WHEN_ADDRESS_CHANGED,
|
||||
DOWNLOAD_TRACKER_FAVICON,
|
||||
SAVE_PATH_HISTORY_LENGTH,
|
||||
ENABLE_SPEED_WIDGET,
|
||||
@ -284,6 +285,8 @@ void AdvancedSettings::saveAdvancedSettings()
|
||||
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)) && defined(QT_DBUS_LIB)
|
||||
mainWindow->setNotificationTimeout(m_spinBoxNotificationTimeout.value());
|
||||
#endif
|
||||
// Reannounce to all trackers when ip/port changed
|
||||
session->setReannounceWhenAddressChangedEnabled(m_checkBoxReannounceWhenAddressChanged.isChecked());
|
||||
// Misc GUI properties
|
||||
mainWindow->setDownloadTrackerFavicon(m_checkBoxTrackerFavicon.isChecked());
|
||||
AddNewTorrentDialog::setSavePathHistoryLength(m_spinBoxSavePathHistoryLength.value());
|
||||
@ -664,6 +667,9 @@ void AdvancedSettings::loadAdvancedSettings()
|
||||
m_spinBoxNotificationTimeout.setSuffix(tr(" ms", " milliseconds"));
|
||||
addRow(NOTIFICATION_TIMEOUT, tr("Notification timeout [0: infinite]"), &m_spinBoxNotificationTimeout);
|
||||
#endif
|
||||
// Reannounce to all trackers when ip/port changed
|
||||
m_checkBoxReannounceWhenAddressChanged.setChecked(session->isReannounceWhenAddressChangedEnabled());
|
||||
addRow(REANNOUNCE_WHEN_ADDRESS_CHANGED, tr("Reannounce to all trackers when IP or port changed"), &m_checkBoxReannounceWhenAddressChanged);
|
||||
// Download tracker's favicon
|
||||
m_checkBoxTrackerFavicon.setChecked(mainWindow->isDownloadTrackerFavicon());
|
||||
addRow(DOWNLOAD_TRACKER_FAVICON, tr("Download tracker's favicon"), &m_checkBoxTrackerFavicon);
|
||||
|
@ -66,7 +66,7 @@ private:
|
||||
m_spinBoxSendBufferWatermarkFactor, m_spinBoxSocketBacklogSize, m_spinBoxMaxConcurrentHTTPAnnounces, m_spinBoxStopTrackerTimeout,
|
||||
m_spinBoxSavePathHistoryLength, m_spinBoxPeerTurnover, m_spinBoxPeerTurnoverCutoff, m_spinBoxPeerTurnoverInterval;
|
||||
QCheckBox m_checkBoxOsCache, m_checkBoxRecheckCompleted, m_checkBoxResolveCountries, m_checkBoxResolveHosts,
|
||||
m_checkBoxProgramNotifications, m_checkBoxTorrentAddedNotifications, m_checkBoxTrackerFavicon, m_checkBoxTrackerStatus,
|
||||
m_checkBoxProgramNotifications, m_checkBoxTorrentAddedNotifications, m_checkBoxReannounceWhenAddressChanged, m_checkBoxTrackerFavicon, m_checkBoxTrackerStatus,
|
||||
m_checkBoxConfirmTorrentRecheck, m_checkBoxConfirmRemoveAllTags, m_checkBoxAnnounceAllTrackers, m_checkBoxAnnounceAllTiers,
|
||||
m_checkBoxMultiConnectionsPerIp, m_checkBoxValidateHTTPSTrackerCertificate, m_checkBoxBlockPeersOnPrivilegedPorts, m_checkBoxPieceExtentAffinity,
|
||||
m_checkBoxSuggestMode, m_checkBoxSpeedWidgetEnabled, m_checkBoxIDNSupport;
|
||||
|
@ -286,6 +286,8 @@ void AppController::preferencesAction()
|
||||
data["recheck_completed_torrents"] = pref->recheckTorrentsOnCompletion();
|
||||
// Resolve peer countries
|
||||
data["resolve_peer_countries"] = pref->resolvePeerCountries();
|
||||
// Reannounce to all trackers when ip/port changed
|
||||
data["reannounce_when_address_changed"] = session->isReannounceWhenAddressChangedEnabled();
|
||||
|
||||
// libtorrent preferences
|
||||
// Async IO threads
|
||||
@ -733,6 +735,9 @@ void AppController::setPreferencesAction()
|
||||
// Resolve peer countries
|
||||
if (hasKey("resolve_peer_countries"))
|
||||
pref->resolvePeerCountries(it.value().toBool());
|
||||
// Reannounce to all trackers when ip/port changed
|
||||
if (hasKey("reannounce_when_address_changed"))
|
||||
session->setReannounceWhenAddressChangedEnabled(it.value().toBool());
|
||||
|
||||
// libtorrent preferences
|
||||
// Async IO threads
|
||||
|
@ -922,6 +922,14 @@
|
||||
<input type="checkbox" id="resolvePeerCountries">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="reannounceWhenAddressChanged">QBT_TR(Reannounce to all trackers when IP or port changed:)QBT_TR[CONTEXT=OptionsDialog]</label>
|
||||
</td>
|
||||
<td>
|
||||
<input type="checkbox" id="reannounceWhenAddressChanged" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="enableEmbeddedTracker">QBT_TR(Enable embedded tracker:)QBT_TR[CONTEXT=OptionsDialog]</label>
|
||||
@ -1882,6 +1890,7 @@
|
||||
$('saveResumeDataInterval').setProperty('value', pref.save_resume_data_interval);
|
||||
$('recheckTorrentsOnCompletion').setProperty('checked', pref.recheck_completed_torrents);
|
||||
$('resolvePeerCountries').setProperty('checked', pref.resolve_peer_countries);
|
||||
$('reannounceWhenAddressChanged').setProperty('checked', pref.reannounce_when_address_changed);
|
||||
// libtorrent section
|
||||
$('asyncIOThreads').setProperty('value', pref.async_io_threads);
|
||||
$('hashingThreads').setProperty('value', pref.hashing_threads);
|
||||
@ -2270,6 +2279,7 @@
|
||||
settings.set('save_resume_data_interval', $('saveResumeDataInterval').getProperty('value'));
|
||||
settings.set('recheck_completed_torrents', $('recheckTorrentsOnCompletion').getProperty('checked'));
|
||||
settings.set('resolve_peer_countries', $('resolvePeerCountries').getProperty('checked'));
|
||||
settings.set('reannounce_when_address_changed', $('reannounceWhenAddressChanged').getProperty('checked'));
|
||||
|
||||
// libtorrent section
|
||||
settings.set('async_io_threads', $('asyncIOThreads').getProperty('value'));
|
||||
|
Loading…
Reference in New Issue
Block a user