Don't call QHostInfo::fromName() to "resolve" an IP address literal

Fixes #1037
This commit is contained in:
Cameron Gutman 2023-07-26 01:59:00 -05:00
parent bfcd373eec
commit 841aeccd6b

View file

@ -274,15 +274,26 @@ bool NvComputer::wake() const
// Try all unique address strings or host names
bool success = false;
for (auto i = addressMap.constBegin(); i != addressMap.constEnd(); i++) {
QHostInfo hostInfo = QHostInfo::fromName(i.key());
QHostAddress literalAddress;
QList<QHostAddress> addressList;
if (hostInfo.error() != QHostInfo::NoError) {
qWarning() << "Error resolving" << i.key() << ":" << hostInfo.errorString();
continue;
// If this is an IPv4/IPv6 literal, don't use QHostInfo::fromName() because that will
// try to perform a reverse DNS lookup that leads to delays sending WoL packets.
if (literalAddress.setAddress(i.key())) {
addressList.append(literalAddress);
}
else {
QHostInfo hostInfo = QHostInfo::fromName(i.key());
if (hostInfo.error() != QHostInfo::NoError) {
qWarning() << "Error resolving" << i.key() << ":" << hostInfo.errorString();
continue;
}
addressList.append(hostInfo.addresses());
}
// Try all IP addresses that this string resolves to
for (QHostAddress& address : hostInfo.addresses()) {
for (QHostAddress& address : addressList) {
QUdpSocket sock;
// Send to all static ports