From: bert hubert Date: Fri, 20 Mar 2015 08:22:10 +0000 (+0100) Subject: remove linktime and runtime dependency on libboost for dnsdist - XXX temporarily... X-Git-Tag: dnsdist-1.0.0-alpha1~248^2~88^2~37 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7cc68f537429ac98276b1c6774a9f5e0ef8b13e5;p=pdns remove linktime and runtime dependency on libboost for dnsdist - XXX temporarily makes non-local binds the default! --- diff --git a/pdns/Makefile.am b/pdns/Makefile.am index d1155c3d3..0fbfbacdd 100644 --- a/pdns/Makefile.am +++ b/pdns/Makefile.am @@ -572,12 +572,11 @@ dnsdist_SOURCES = \ sstuff.hh dnsdist_LDFLAGS = \ - $(AM_LDFLAGS) \ - $(BOOST_PROGRAM_OPTIONS_LDFLAGS) + $(AM_LDFLAGS) dnsdist_LDADD = \ -lreadline -lrt -ltermcap \ - $(BOOST_PROGRAM_OPTIONS_LIBS) $(LUA_LIBS) ${libsodium_LIBS} + $(LUA_LIBS) ${libsodium_LIBS} nsec3dig_SOURCES = \ base32.cc \ diff --git a/pdns/dnsdist.cc b/pdns/dnsdist.cc index 61850447b..7f2f40c32 100644 --- a/pdns/dnsdist.cc +++ b/pdns/dnsdist.cc @@ -32,11 +32,13 @@ #include "dnswriter.hh" #include "base64.hh" #include + +#include #include "sodcrypto.hh" #include "dnsrulactions.hh" -#include + +#include #undef L -namespace po = boost::program_options; /* Known sins: No centralized statistics @@ -52,8 +54,6 @@ namespace po = boost::program_options; On the C++ side, both could be inherited from a class Rule and a class Action, on the Lua side we can't do that. */ -namespace po = boost::program_options; -po::variables_map g_vm; using std::atomic; using std::thread; bool g_verbose; @@ -66,6 +66,7 @@ GlobalStateHolder g_ACL; string g_outputBuffer; vector g_locals; + /* UDP: the grand design. Per socket we listen on for incoming queries there is one thread. Then we have a bunch of connected sockets for talking to downstream servers. We send directly to those sockets. @@ -811,7 +812,7 @@ catch(std::exception& e) -void doClient(ComboAddress server) +void doClient(ComboAddress server, const std::string& command) { cout<<"Connecting to "<(); + if(!command.empty()) { string response; string msg=sodEncryptSym(command, g_key, ours); putMsgLen(fd, msg.length()); @@ -1012,6 +1012,15 @@ static char** my_completion( const char * text , int start, int end) } } +struct +{ + vector locals; + vector remotes; + bool beDaemon{false}; + bool beClient{false}; + string command; + string config; +} g_cmdLine; int main(int argc, char** argv) @@ -1032,51 +1041,80 @@ try } #endif - po::options_description desc("Allowed options"), hidden, alloptions; - desc.add_options() - ("help,h", "produce help message") - ("bind-non-local", "allow binding to non-local addresses") - ("config", po::value()->default_value("/etc/dnsdist.conf"), "Filename with our configuration") - ("client", "be a client") - ("command,c", po::value(), "Execute this command on a running dnsdist") - ("daemon", po::value()->default_value(true), "run in background") - ("local", po::value >(), "Listen on which addresses") - ("max-outstanding", po::value()->default_value(1024), "maximum outstanding queries per downstream") - ("verbose,v", "be verbose"); - - hidden.add_options() - ("remotes", po::value >(), "remote-host"); - - alloptions.add(desc).add(hidden); - - po::positional_options_description p; - p.add("remotes", -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")) { - cout << desc<(); + g_maxOutstanding = 1024; ServerPolicy leastOutstandingPol{"leastOutstanding", leastOutstanding}; g_policy.setState(leastOutstandingPol); - if(g_vm.count("client") || g_vm.count("command")) { - setupLua(true, g_vm["config"].as()); - doClient(g_serverControl); + if(g_cmdLine.beClient || !g_cmdLine.command.empty()) { + setupLua(true, g_cmdLine.config); + doClient(g_serverControl, g_cmdLine.command); exit(EXIT_SUCCESS); } - auto todo=setupLua(false, g_vm["config"].as()); + auto todo=setupLua(false, g_cmdLine.config); - if(g_vm.count("local")) { + if(g_cmdLine.locals.size()) { g_locals.clear(); - for(auto loc : g_vm["local"].as >()) + for(auto loc : g_cmdLine.locals) g_locals.push_back(ComboAddress(loc, 53)); } @@ -1092,8 +1130,8 @@ try if(cs->local.sin4.sin_family == AF_INET6) { SSetsockopt(cs->udpFD, IPPROTO_IPV6, IPV6_V6ONLY, 1); } - if(g_vm.count("bind-non-local")) - bindAny(local.sin4.sin_family, cs->udpFD); + //if(g_vm.count("bind-non-local")) + bindAny(local.sin4.sin_family, cs->udpFD); // setSocketTimestamps(cs->udpFD); @@ -1107,7 +1145,7 @@ try toLaunch.push_back(cs); } - if(g_vm["daemon"].as()) { + if(g_cmdLine.beDaemon) { g_console=false; daemonize(); } @@ -1123,8 +1161,8 @@ try acl.addMask(addr); g_ACL.setState(acl); - if(g_vm.count("remotes")) { - for(const auto& address : g_vm["remotes"].as>()) { + if(g_cmdLine.remotes.size()) { + for(const auto& address : g_cmdLine.remotes) { auto ret=std::make_shared(ComboAddress(address, 53)); ret->tid = move(thread(responderThread, ret)); g_dstates.modify([ret](servers_t& servers) { servers.push_back(ret); }); @@ -1158,7 +1196,7 @@ try if(cs->local.sin4.sin_family == AF_INET6) { SSetsockopt(cs->tcpFD, IPPROTO_IPV6, IPV6_V6ONLY, 1); } - if(g_vm.count("bind-non-local")) + // if(g_vm.count("bind-non-local")) bindAny(cs->local.sin4.sin_family, cs->tcpFD); SBind(cs->tcpFD, cs->local); SListen(cs->tcpFD, 64); @@ -1170,7 +1208,7 @@ try thread stattid(maintThread); - if(!g_vm["daemon"].as()) { + if(!g_cmdLine.beDaemon) { stattid.detach(); doConsole(); } diff --git a/pdns/dnsdistdist/Makefile.am b/pdns/dnsdistdist/Makefile.am index 406030b3b..b0e6536f6 100644 --- a/pdns/dnsdistdist/Makefile.am +++ b/pdns/dnsdistdist/Makefile.am @@ -29,9 +29,9 @@ dnsdist_SOURCES = \ dnsdist_LDFLAGS = \ $(AM_LDFLAGS) \ - $(BOOST_PROGRAM_OPTIONS_LDFLAGS) -pthread + -pthread dnsdist_LDADD = \ -lreadline -lrt -ltermcap \ - $(BOOST_PROGRAM_OPTIONS_LIBS) $(LUA_LIBS) ${libsodium_LIBS} + $(LUA_LIBS) ${libsodium_LIBS} diff --git a/pdns/dnsdistdist/configure.ac b/pdns/dnsdistdist/configure.ac index b6699b6ed..a891cd519 100644 --- a/pdns/dnsdistdist/configure.ac +++ b/pdns/dnsdistdist/configure.ac @@ -9,8 +9,6 @@ PKG_CHECK_MODULES([libsodium], [libsodium], [AC_DEFINE([HAVE_LIBSODIUM], [1], [D AC_PROG_LIBTOOL BOOST_REQUIRE([1.35]) BOOST_FOREACH -BOOST_PROGRAM_OPTIONS([mt]) - PDNS_WITH_LUA AX_CXX_COMPILE_STDCXX_11(ext,mandatory)