From 2b694aae4796d05dca6e12392c920f9f2ba86e4f Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 19 Apr 2024 09:48:42 -0700 Subject: [PATCH] qdnslookup tool: add the ability to resolve hostnames MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We always just take the first, which QHostInfo should have sorted in priority order. Change-Id: I455fe22ef4ad4b2f9b01fffd17c7bc6460f06b98 Reviewed-by: MÃ¥rten Nordheim --- tests/manual/qdnslookup/main.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/manual/qdnslookup/main.cpp b/tests/manual/qdnslookup/main.cpp index aa80f4df787..a07eac6d45f 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 addresses = hostinfo.addresses(); + if (!hostinfo.error() && !addresses.isEmpty()) + r.address = addresses.at(0); + } return r; }