]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
strip dnsdist down to the bare essentials
authorbert hubert <bert.hubert@netherlabs.nl>
Sat, 7 Mar 2015 21:46:12 +0000 (22:46 +0100)
committerbert hubert <bert.hubert@netherlabs.nl>
Sat, 7 Mar 2015 21:46:12 +0000 (22:46 +0100)
pdns/Makefile.am
pdns/dnsdist-lua.cc
pdns/dnsdist.cc

index 0e2e2f63a62a3daa266a5b5732a175657d2f5de3..bd05946bc4b842df68957e235f5d6be4e5a4fca7 100644 (file)
@@ -556,30 +556,19 @@ dnstcpbench_LDADD = \
        $(BOOST_PROGRAM_OPTIONS_LIBS)
 
 dnsdist_SOURCES = \
-       arguments.cc \
        base32.cc \
        base64.cc base64.hh \
-       dns.cc \
        dnsdist.cc \
        dnsdist-lua.cc \
        dnslabeltext.cc \
        dnsname.cc dnsname.hh \
-       dnsparser.cc dnsparser.hh \
-       dnsrecords.cc \
-       dnswriter.cc dnswriter.hh \
+       dnswriter.cc \
        dolog.hh \
        iputils.cc \
-       logger.cc \
-       lua-iputils.cc \
        misc.cc misc.hh \
-       nsecrecords.cc \
        qtype.cc \
-       rcpgenerator.cc rcpgenerator.hh \
-       sillyrecords.cc \
        sodcrypto.cc sodcrypto.hh \
-       sstuff.hh \
-       statbag.cc \
-       unix_utility.cc
+       sstuff.hh 
 
 dnsdist_LDFLAGS = \
        $(AM_LDFLAGS) \
index c036e8f50a1e72dea7aceee4fa3f1fde01b70f34..38202f9bc2ab28b7710ee57814b75fe6a7ceee7c 100644 (file)
@@ -106,7 +106,9 @@ vector<std::function<void(void)>> setupLua(bool client)
   g_lua.writeVariable("wrandom", ServerPolicy{"wrandom", wrandom});
   g_lua.writeVariable("leastOutstanding", ServerPolicy{"leastOutstanding", leastOutstanding});
   g_lua.writeFunction("addACL", [](const std::string& domain) {
-      g_ACL.addMask(domain);
+      auto state=g_ACL.getCopy();
+      state->addMask(domain);
+      g_ACL.setState(state);
     });
 
   g_lua.writeFunction("addLocal", [client](const std::string& addr) {
@@ -121,19 +123,20 @@ vector<std::function<void(void)>> setupLua(bool client)
       }
     });
   g_lua.writeFunction("setACL", [](const vector<pair<int, string>>& parts) {
-    NetmaskGroup nmg;
-    for(const auto& p : parts) {
-      nmg.addMask(p.second);
-    }
-    g_ACL=nmg;
+      auto nmg = std::make_shared<NetmaskGroup>();
+      for(const auto& p : parts) {
+       nmg->addMask(p.second);
+      }
+      g_ACL.setState(nmg);
   });
   g_lua.writeFunction("showACL", []() {
       vector<string> vec;
-      g_ACL.toStringVector(&vec);
-      string ret;
+
+      g_ACL.getCopy()->toStringVector(&vec);
+
       for(const auto& s : vec)
-       ret+=s+"\n";
-      return ret;
+        g_outputBuffer+=s+"\n";
+
     });
   g_lua.writeFunction("shutdown", []() { _exit(0);} );
 
@@ -376,7 +379,7 @@ vector<std::function<void(void)>> setupLua(bool client)
        }
 
       }
-      cout<<"Looked at "<<total<<" queries, "<<counts.size()<<" different ones"<<endl;
+      // cout<<"Looked at "<<total<<" queries, "<<counts.size()<<" different ones"<<endl;
       vector<pair<int, DNSName>> rcounts;
       for(const auto& c : counts) 
        rcounts.push_back(make_pair(c.second, c.first));
index bbce2725aed7c884c82e463608d83e9a379641bf..26fe837acda06482d474d072bb5fbcbfd23d2bbf 100644 (file)
 #include "dnsdist.hh"
 #include "sstuff.hh"
 #include "misc.hh"
-#include "statbag.hh"
 #include <netinet/tcp.h>
 
 
 
 #include <limits>
 
-#include "arguments.hh"
 #include "dolog.hh"
 #include <readline/readline.h>
 #include <readline/history.h>
    we offer now way to log from Lua
 */
 
-ArgvMap& arg()
-{
-  static ArgvMap a;
-  return a;
-}
-StatBag S;
 namespace po = boost::program_options;
 po::variables_map g_vm;
 using std::atomic;
@@ -68,7 +60,8 @@ atomic<uint64_t> g_pos;
 atomic<uint64_t> g_regexBlocks;
 uint16_t g_maxOutstanding;
 bool g_console;
-NetmaskGroup g_ACL;
+
+GlobalStateHolder<NetmaskGroup> g_ACL;
 string g_outputBuffer;
 vector<ComboAddress> g_locals;
 
@@ -303,13 +296,15 @@ try
     if(candidate)
       blockFilter = *candidate;
   }
+  auto acl = g_ACL.getLocal();
   for(;;) {
     try {
       len = recvfrom(cs->udpFD, packet, sizeof(packet), 0, (struct sockaddr*) &remote, &socklen);
       if(len < (int)sizeof(struct dnsheader)) 
        continue;
+
       
-      if(!g_ACL.match(remote))
+      if(!acl->match(remote))
        continue;
       
       if(dh->qr)    // don't respond to responses
@@ -999,9 +994,10 @@ try
   for(auto& t : todo)
     t();
 
+  auto acl = g_ACL.getCopy();
   for(auto& addr : {"127.0.0.0/8", "10.0.0.0/8", "100.64.0.0/10", "169.254.0.0/16", "192.168.0.0/16", "172.16.0.0/12", "::1/128", "fc00::/7", "fe80::/10"})
-    g_ACL.addMask(addr);
-
+    acl->addMask(addr);
+  g_ACL.setState(acl);
 
   if(g_vm.count("remotes")) {
     for(const auto& address : g_vm["remotes"].as<vector<string>>()) {