diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2024-04-19 09:48:42 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2024-04-24 12:36:48 -0700 |
commit | 2b694aae4796d05dca6e12392c920f9f2ba86e4f (patch) | |
tree | 52039f6708f98ca8b7de66070418d47b8e792ee2 | |
parent | 1d17604c65803f900c751bd6386fc243c0291f06 (diff) |
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>
-rw-r--r-- | tests/manual/qdnslookup/main.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/manual/qdnslookup/main.cpp b/tests/manual/qdnslookup/main.cpp index aa80f4df78..a07eac6d45 100644 --- a/tests/manual/qdnslookup/main.cpp +++ b/tests/manual/qdnslookup/main.cpp @@ -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; } |