qdnslookup tool: add the ability to resolve hostnames
We always just take the first, which QHostInfo should have sorted in priority order. Change-Id: I455fe22ef4ad4b2f9b01fffd17c7bc6460f06b98 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
parent
1d17604c65
commit
2b694aae47
@ -54,6 +54,13 @@ static auto parseServerAddress(QString server)
|
||||
|
||||
r.port = url.port();
|
||||
r.address.setAddress(url.host());
|
||||
if (r.address.isNull()) {
|
||||
// try to resolve a hostname
|
||||
QHostInfo hostinfo = QHostInfo::fromName(url.host());
|
||||
const QList<QHostAddress> addresses = hostinfo.addresses();
|
||||
if (!hostinfo.error() && !addresses.isEmpty())
|
||||
r.address = addresses.at(0);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user