From: Pieter Lexis Date: Wed, 10 Jan 2018 12:11:44 +0000 (+0100) Subject: Initial options for ixfrdist X-Git-Tag: dnsdist-1.3.0~111^2~31 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a2670f5ebeec6c24a9083f9407ef6d6086f0da7c;p=pdns Initial options for ixfrdist --- diff --git a/pdns/.gitignore b/pdns/.gitignore index e48ccf408..9ffd6c31e 100644 --- a/pdns/.gitignore +++ b/pdns/.gitignore @@ -29,6 +29,7 @@ /dnsscope /dnstcpbench /dnswasher +/ixfrdist /ixplore /kvresp /pdns_notify diff --git a/pdns/Makefile.am b/pdns/Makefile.am index e3cce9a17..d497358d6 100644 --- a/pdns/Makefile.am +++ b/pdns/Makefile.am @@ -95,6 +95,7 @@ bin_PROGRAMS += \ saxfr \ stubquery \ ixplore \ + ixfrdist \ sdig if HAVE_RECVMMSG @@ -123,6 +124,7 @@ EXTRA_PROGRAMS = \ dumresp \ kvresp \ ixplore \ + ixfrdist \ pdns_notify \ nproxy \ nsec3dig \ @@ -586,6 +588,51 @@ if GSS_TSIG saxfr_LDADD += $(GSS_LIBS) endif +ixfrdist_SOURCES = \ + arguments.cc \ + base32.cc \ + base64.cc base64.hh \ + dns.cc \ + dns_random.cc dns_random.hh \ + dnslabeltext.cc \ + dnsname.cc dnsname.hh \ + dnsparser.cc dnsparser.hh \ + dnsrecords.cc \ + dnssecinfra.cc \ + dnswriter.cc dnswriter.hh \ + gss_context.cc gss_context.hh \ + logger.cc \ + misc.cc misc.hh \ + nsecrecords.cc \ + qtype.cc \ + rcpgenerator.cc rcpgenerator.hh \ + resolver.cc \ + ixfr.cc ixfr.hh \ + ixfrdist.cc \ + sillyrecords.cc \ + sstuff.hh \ + statbag.cc \ + tsigverifier.cc tsigverifier.hh \ + unix_utility.cc zoneparser-tng.cc + +ixfrdist_LDADD = \ + $(BOOST_PROGRAM_OPTIONS_LIBS) \ + $(LIBCRYPTO_LIBS) + +ixfrdist_LDFLAGS = \ + $(AM_LDFLAGS) \ + $(BOOST_PROGRAM_OPTIONS_LDFLAGS) \ + $(LIBCRYPTO_LDFLAGS) + +if PKCS11 +ixfrdist_SOURCES += pkcs11signers.cc pkcs11signers.hh +ixfrdist_LDADD += $(P11KIT1_LIBS) +endif + +if GSS_TSIG +ixfrdist_LDADD += $(GSS_LIBS) +endif + ixplore_SOURCES = \ arguments.cc \ diff --git a/pdns/ixfrdist.cc b/pdns/ixfrdist.cc new file mode 100644 index 000000000..fb59ac0ff --- /dev/null +++ b/pdns/ixfrdist.cc @@ -0,0 +1,137 @@ +/* + * This file is part of PowerDNS or dnsdist. + * Copyright -- PowerDNS.COM B.V. and its contributors + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * In addition, for the avoidance of any doubt, permission is granted to + * link this program with OpenSSL and to (re)distribute the binaries + * produced as the result of such linking. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif +#include "arguments.hh" +#include "base64.hh" +#include +#include + +#include "dnsparser.hh" +#include "sstuff.hh" +#include "misc.hh" +#include "dnswriter.hh" +#include "dnsrecords.hh" +#include "statbag.hh" +#include "base32.hh" +#include "dnssecinfra.hh" + +#include "dns_random.hh" +#include "gss_context.hh" +#include "zoneparser-tng.hh" +#include +#include +#include "resolver.hh" +#include +#include "ixfr.hh" +using namespace boost::multi_index; +StatBag S; + +ArgvMap &arg() +{ + static ArgvMap theArg; + return theArg; +} + +namespace po = boost::program_options; +po::variables_map g_vm; + +void usage(po::options_description &desc) { + cerr << "Usage: ixfrdist [OPTION]... DOMAIN [DOMAIN]..."<>(), "IP Address(es) to listen on") + ("server-address", po::value()->default_value("127.0.0.1:5300"), "server address") + ("work-dir", po::value()->default_value("."), "Directory for storing AXFR and IXFR data") + ; + po::options_description alloptions; + po::options_description hidden("hidden options"); + hidden.add_options() + ("domains", po::value< vector >(), "domains"); + + alloptions.add(desc).add(hidden); + po::positional_options_description p; + p.add("domains", -1); + + po::store(po::command_line_parser(argc, argv).options(alloptions).positional(p).run(), g_vm); + po::notify(g_vm); + + if (g_vm.count("help")) { + usage(desc); + return EXIT_SUCCESS; + } + + if (g_vm.count("version")) { + cout<<"ixfrdist "< listen_addresses = {ComboAddress("127.0.0.1:53")}; + + if (g_vm.count("listen-address")) { + listen_addresses.clear(); + for (const auto &addr : g_vm["listen-address"].as< vector< string> >()) { + try { + listen_addresses.push_back(ComboAddress(addr, 53)); + } catch(PDNSException &e) { + cerr<<"[Error] listen-address '"<(), 53); + } catch(PDNSException &e) { + cerr<<"[Error] server-address '"<()<<"' is not an IP address: "< domains; + + for (const auto &domain : g_vm["domains"].as>()) { + try { + domains.push_back(DNSName(domain)); + } catch (PDNSException &e) { + cerr<<"[Error] '"<