Examples: Add support for custom nameserver to dnslookup
Updated dnslookup example to take an optional nameserver argument for doing DNS lookup against a specific nameserver. Task-number: QTBUG-30166 Change-Id: I9f46f9f766b56f770d2c8372e3bfad5c71023c73 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
1de459a6dd
commit
60dc35e428
@ -50,7 +50,7 @@
|
||||
|
||||
static void usage() {
|
||||
printf("Qt DNS example - performs DNS lookups\n"
|
||||
"Usage: dnslookup [-t <type>] name\n\n");
|
||||
"Usage: dnslookup [-t <type>] [-s nameserver] name\n\n");
|
||||
}
|
||||
|
||||
DnsManager::DnsManager()
|
||||
@ -93,6 +93,17 @@ void DnsManager::execute()
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (args.size() > 1 && args.first() == "-s") {
|
||||
args.takeFirst();
|
||||
const QString ns = args.takeFirst();
|
||||
QHostAddress nameserver(ns);
|
||||
if (nameserver.isNull() || nameserver.protocol() == QAbstractSocket::UnknownNetworkLayerProtocol) {
|
||||
printf("Bad nameserver address: %s\n", qPrintable(ns));
|
||||
QCoreApplication::instance()->quit();
|
||||
return;
|
||||
}
|
||||
dns->setNameserver(nameserver);
|
||||
}
|
||||
if (args.isEmpty()) {
|
||||
usage();
|
||||
QCoreApplication::instance()->quit();
|
||||
|
Loading…
x
Reference in New Issue
Block a user