summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2024-04-17 22:05:04 -0700
committerThiago Macieira <thiago.macieira@intel.com>2024-04-22 21:36:30 -0700
commit6800e168d5ac780f57a4659b0636bc2f072440a2 (patch)
tree134a8c86bb587b351e4ba94a126d119f085fc075
parentf7d293d3da285ed4cff01f471dd752e87059b217 (diff)
tst_QDnsLookup: also use the nameservers behind systemd-resolved
If the file exists, we are using systemd-resolved, so let's try directly using the nameservers it uses. Change-Id: I455fe22ef4ad4b2f9b01fffd17c7476a2385bf4b Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
-rw-r--r--tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp30
1 files changed, 17 insertions, 13 deletions
diff --git a/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp b/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp
index cfb764e796..b4619166cc 100644
--- a/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp
+++ b/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp
@@ -91,19 +91,23 @@ static QList<QHostAddress> systemNameservers()
}
}
#else
- QFile f("/etc/resolv.conf");
- if (!f.open(QIODevice::ReadOnly))
- return result;
-
- while (!f.atEnd()) {
- static const char command[] = "nameserver";
- QByteArray line = f.readLine().simplified();
- if (!line.startsWith(command))
- continue;
-
- QString addr = QLatin1StringView(line).mid(sizeof(command));
- result.emplaceBack(addr);
- }
+ auto parseFile = [&](QLatin1StringView path) {
+ QFile f(path);
+ if (!f.open(QIODevice::ReadOnly))
+ return;
+
+ while (!f.atEnd()) {
+ static const char command[] = "nameserver";
+ QByteArray line = f.readLine().simplified();
+ if (!line.startsWith(command))
+ continue;
+
+ QString addr = QLatin1StringView(line).mid(sizeof(command));
+ result.emplaceBack(addr);
+ }
+ };
+ parseFile("/etc/resolv.conf"_L1);
+ parseFile("/run/systemd/resolve/resolv.conf"_L1);
#endif
return result;