mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 21:15:33 +08:00
Remove redundant checks in CNetworkUtils::getKnownLocalIpV4Addresses()
refs #869
This commit is contained in:
committed by
Mathew Sutcliffe
parent
7edd1bb621
commit
98b2061d3d
@@ -94,17 +94,14 @@ namespace BlackMisc
|
||||
QStringList CNetworkUtils::getKnownLocalIpV4Addresses()
|
||||
{
|
||||
QStringList ips;
|
||||
if (!CNetworkUtils::hasConnectedInterface(false)) {return ips; }
|
||||
for (const QHostAddress &address : QNetworkInterface::allAddresses())
|
||||
const QList<QHostAddress> allAddresses = QNetworkInterface::allAddresses();
|
||||
for (const QHostAddress &address : allAddresses)
|
||||
{
|
||||
if (address.isLoopback() || address.isNull()) continue;
|
||||
if (address.protocol() == QAbstractSocket::IPv4Protocol && address != QHostAddress(QHostAddress::LocalHost))
|
||||
if (address.isNull()) { continue; }
|
||||
if (address.protocol() == QAbstractSocket::IPv4Protocol)
|
||||
{
|
||||
QString a = address.toString();
|
||||
if (CNetworkUtils::isValidIPv4Address(a))
|
||||
{
|
||||
ips.append(a);
|
||||
}
|
||||
ips.append(a);
|
||||
}
|
||||
}
|
||||
ips.sort();
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace BlackMisc
|
||||
//! Can connect to URL?
|
||||
static bool canConnect(const BlackMisc::Network::CUrl &url, int timeoutMs = getTimeoutMs());
|
||||
|
||||
//! Find out my IPv4 address, empty if not possible
|
||||
//! Find out my IPv4 addresses including loopback, empty if not possible
|
||||
static QStringList getKnownLocalIpV4Addresses();
|
||||
|
||||
//! Valid IPv4 address
|
||||
|
||||
Reference in New Issue
Block a user