Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

network: networkmanager: Check if IP is IPv4/6 before checking mDNS #1042

Merged
merged 1 commit into from Mar 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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