]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
make last two args optional
authorPeter van Dijk <peter.van.dijk@powerdns.com>
Thu, 18 Jul 2024 17:29:15 +0000 (19:29 +0200)
committerPeter van Dijk <peter.van.dijk@powerdns.com>
Thu, 18 Jul 2024 17:29:15 +0000 (19:29 +0200)
docs/manpages/pdnsutil.1.rst
pdns/pdnsutil.cc

index acfc231ae9663d5ff51d157ec2c3f55eeeedd153..b6c411323b73de4e6c846db8de5bf470cf7f6954 100644 (file)
@@ -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.
index 917dd03819a27c4dd0c70ee27820a9c603451fad..f84a31b24fcc712f95f0a4efdf315cf22f2bdc96 100644 (file)
@@ -1,6 +1,7 @@
 #include "dnsname.hh"
 #include "dnsparser.hh"
 #include "dnsrecords.hh"
+#include "qtype.hh"
 #include <boost/smart_ptr/make_shared_array.hpp>
 #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);