$(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) \
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) {
}
});
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);} );
}
}
- 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));
#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;
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;
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
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>>()) {