Skip to content

Commit

Permalink
network: networkmanager: Check if IP is IPv4/6 before checking mDNS
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick Jo Pereira <patrickelectric@gmail.com>
  • Loading branch information
patrickelectric committed Mar 7, 2022
1 parent f86c9c2 commit 36168c2
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/network/networkmanager.cpp
Expand Up @@ -78,6 +78,15 @@ void NetworkManager::download(const QUrl& url, std::function<void(QString)> func

QHostAddress NetworkManager::addressToIp(const QString& address)
{
const QHostAddress testAddress(address);

// Check first if the address is a valid IPV4/6 and avoid calling QHostInfo::fromName
if (testAddress.protocol() == QAbstractSocket::IPv4Protocol
|| testAddress.protocol() == QAbstractSocket::IPv6Protocol) {
return testAddress;
}

// This function can freeze the interface if something is wrong with the OS mDNS interface
return QHostInfo::fromName(address).addresses().first();
}

Expand Down

0 comments on commit 36168c2

Please sign in to comment.