mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-20 23:47:23 -06:00
Display External IP Address in status bar
This change displays the last detected IPv4 and/or IPv6 address(es) in the GUI and WebUI's status bar. This does not yet handle systems with multiple addresses of the same type (e.g. multiple IPv6 addresses). PR #21383. --------- Co-authored-by: Odin Vex <44311901+OdinVex@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
fb9b3c0f34
commit
f89c4c32ed
@@ -468,6 +468,9 @@ namespace BitTorrent
|
||||
virtual void topTorrentsQueuePos(const QList<TorrentID> &ids) = 0;
|
||||
virtual void bottomTorrentsQueuePos(const QList<TorrentID> &ids) = 0;
|
||||
|
||||
virtual QString lastExternalIPv4Address() const = 0;
|
||||
virtual QString lastExternalIPv6Address() const = 0;
|
||||
|
||||
signals:
|
||||
void startupProgressUpdated(int progress);
|
||||
void addTorrentFailed(const InfoHash &infoHash, const QString &reason);
|
||||
|
||||
@@ -4967,6 +4967,16 @@ void SessionImpl::setTrackerFilteringEnabled(const bool enabled)
|
||||
}
|
||||
}
|
||||
|
||||
QString SessionImpl::lastExternalIPv4Address() const
|
||||
{
|
||||
return m_lastExternalIPv4Address;
|
||||
}
|
||||
|
||||
QString SessionImpl::lastExternalIPv6Address() const
|
||||
{
|
||||
return m_lastExternalIPv6Address;
|
||||
}
|
||||
|
||||
bool SessionImpl::isListening() const
|
||||
{
|
||||
return m_nativeSessionExtension->isSessionListening();
|
||||
@@ -5988,11 +5998,19 @@ void SessionImpl::handleExternalIPAlert(const lt::external_ip_alert *alert)
|
||||
LogMsg(tr("Detected external IP. IP: \"%1\"")
|
||||
.arg(externalIP), Log::INFO);
|
||||
|
||||
if (m_lastExternalIP != externalIP)
|
||||
const bool isIPv6 = alert->external_address.is_v6();
|
||||
const bool isIPv4 = alert->external_address.is_v4();
|
||||
if (isIPv6 && (externalIP != m_lastExternalIPv6Address))
|
||||
{
|
||||
if (isReannounceWhenAddressChangedEnabled() && !m_lastExternalIP.isEmpty())
|
||||
if (isReannounceWhenAddressChangedEnabled() && !m_lastExternalIPv6Address.isEmpty())
|
||||
reannounceToAllTrackers();
|
||||
m_lastExternalIP = externalIP;
|
||||
m_lastExternalIPv6Address = externalIP;
|
||||
}
|
||||
else if (isIPv4 && (externalIP != m_lastExternalIPv4Address))
|
||||
{
|
||||
if (isReannounceWhenAddressChangedEnabled() && !m_lastExternalIPv4Address.isEmpty())
|
||||
reannounceToAllTrackers();
|
||||
m_lastExternalIPv4Address = externalIP;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -443,6 +443,9 @@ namespace BitTorrent
|
||||
void topTorrentsQueuePos(const QList<TorrentID> &ids) override;
|
||||
void bottomTorrentsQueuePos(const QList<TorrentID> &ids) override;
|
||||
|
||||
QString lastExternalIPv4Address() const override;
|
||||
QString lastExternalIPv6Address() const override;
|
||||
|
||||
// Torrent interface
|
||||
void handleTorrentResumeDataRequested(const TorrentImpl *torrent);
|
||||
void handleTorrentShareLimitChanged(TorrentImpl *torrent);
|
||||
@@ -813,7 +816,8 @@ namespace BitTorrent
|
||||
|
||||
QList<MoveStorageJob> m_moveStorageQueue;
|
||||
|
||||
QString m_lastExternalIP;
|
||||
QString m_lastExternalIPv4Address;
|
||||
QString m_lastExternalIPv6Address;
|
||||
|
||||
bool m_needUpgradeDownloadPath = false;
|
||||
|
||||
|
||||
@@ -359,6 +359,19 @@ void Preferences::setStatusbarDisplayed(const bool displayed)
|
||||
setValue(u"Preferences/General/StatusbarDisplayed"_s, displayed);
|
||||
}
|
||||
|
||||
bool Preferences::isStatusbarExternalIPDisplayed() const
|
||||
{
|
||||
return value(u"Preferences/General/StatusbarExternalIPDisplayed"_s, false);
|
||||
}
|
||||
|
||||
void Preferences::setStatusbarExternalIPDisplayed(const bool displayed)
|
||||
{
|
||||
if (displayed == isStatusbarExternalIPDisplayed())
|
||||
return;
|
||||
|
||||
setValue(u"Preferences/General/StatusbarExternalIPDisplayed"_s, displayed);
|
||||
}
|
||||
|
||||
bool Preferences::isSplashScreenDisabled() const
|
||||
{
|
||||
return value(u"Preferences/General/NoSplashScreen"_s, true);
|
||||
|
||||
@@ -119,6 +119,8 @@ public:
|
||||
void setHideZeroComboValues(int n);
|
||||
bool isStatusbarDisplayed() const;
|
||||
void setStatusbarDisplayed(bool displayed);
|
||||
bool isStatusbarExternalIPDisplayed() const;
|
||||
void setStatusbarExternalIPDisplayed(bool displayed);
|
||||
bool isToolbarDisplayed() const;
|
||||
void setToolbarDisplayed(bool displayed);
|
||||
bool isSplashScreenDisabled() const;
|
||||
|
||||
Reference in New Issue
Block a user