mirror of
https://github.com/moonlight-stream/moonlight-qt
synced 2025-01-24 08:35:01 +00:00
Don't call QHostInfo::fromName() to "resolve" an IP address literal
Fixes #1037
This commit is contained in:
parent
bfcd373eec
commit
841aeccd6b
1 changed files with 16 additions and 5 deletions
|
@ -274,15 +274,26 @@ bool NvComputer::wake() const
|
||||||
// Try all unique address strings or host names
|
// Try all unique address strings or host names
|
||||||
bool success = false;
|
bool success = false;
|
||||||
for (auto i = addressMap.constBegin(); i != addressMap.constEnd(); i++) {
|
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) {
|
// If this is an IPv4/IPv6 literal, don't use QHostInfo::fromName() because that will
|
||||||
qWarning() << "Error resolving" << i.key() << ":" << hostInfo.errorString();
|
// try to perform a reverse DNS lookup that leads to delays sending WoL packets.
|
||||||
continue;
|
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
|
// Try all IP addresses that this string resolves to
|
||||||
for (QHostAddress& address : hostInfo.addresses()) {
|
for (QHostAddress& address : addressList) {
|
||||||
QUdpSocket sock;
|
QUdpSocket sock;
|
||||||
|
|
||||||
// Send to all static ports
|
// Send to all static ports
|
||||||
|
|
Loading…
Reference in a new issue