From: Peter van Dijk Date: Thu, 18 Jul 2024 17:29:15 +0000 (+0200) Subject: make last two args optional X-Git-Tag: rec-5.2.0-alpha1~156^2~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=52ea9a74e626e332e237140969b5fd1d0173a9d2;p=thirdparty%2Fpdns.git make last two args optional --- diff --git a/docs/manpages/pdnsutil.1.rst b/docs/manpages/pdnsutil.1.rst index acfc231ae9..b6c411323b 100644 --- a/docs/manpages/pdnsutil.1.rst +++ b/docs/manpages/pdnsutil.1.rst @@ -283,7 +283,7 @@ backend-cmd *BACKEND* *CMD* [*CMD...*] Send a text command to a backend for execution. GSQL backends will take SQL commands, other backends may take different things. Be careful! -backend-lookup *BACKEND* *NAME* *TYPE* *CLIENT-IP-SUBNET* +backend-lookup *BACKEND* *NAME* [*TYPE* [*CLIENT-IP-SUBNET*]] Perform a backend record filtering lookup. bench-db [*FILE*] Perform a benchmark of the backend-database. diff --git a/pdns/pdnsutil.cc b/pdns/pdnsutil.cc index 917dd03819..f84a31b24f 100644 --- a/pdns/pdnsutil.cc +++ b/pdns/pdnsutil.cc @@ -1,6 +1,7 @@ #include "dnsname.hh" #include "dnsparser.hh" #include "dnsrecords.hh" +#include "qtype.hh" #include #ifdef HAVE_CONFIG_H #include "config.h" @@ -4230,8 +4231,8 @@ try return 0; } else if (cmds.at(0) == "backend-lookup") { - if (cmds.size() < 5) { - cerr << "Usage: backend-lookup BACKEND NAME TYPE CLIENT-IP-SUBNET" << endl; + if (cmds.size() < 3) { + cerr << "Usage: backend-lookup BACKEND NAME [TYPE [CLIENT-IP-SUBNET]]" << endl; return 1; } @@ -4248,14 +4249,18 @@ try return 1; } - QType type; - type = DNSRecordContent::TypeToNumber(cmds.at(3)); + QType type = QType::ANY; + if (cmds.size() > 3) { + type = DNSRecordContent::TypeToNumber(cmds.at(3)); + } DNSName name{cmds.at(2)}; DNSPacket queryPacket(true); - Netmask clientNetmask(cmds.at(4)); - queryPacket.setRealRemote(clientNetmask); + if (cmds.size() > 4) { + Netmask clientNetmask(cmds.at(4)); + queryPacket.setRealRemote(clientNetmask); + } matchingBackend->lookup(type, name, -1, &queryPacket);