vector<std::function<void(void)>> setupLua(bool client, const std::string& config)
{
g_launchWork= new vector<std::function<void(void)>>();
- typedef std::unordered_map<std::string, boost::variant<std::string, vector<pair<int, std::string> > > > newserver_t;
+ typedef std::unordered_map<std::string, boost::variant<bool, std::string, vector<pair<int, std::string> > > > newserver_t;
g_lua.writeVariable("DNSAction", std::unordered_map<string,int>{
{"Drop", (int)DNSAction::Action::Drop},
ret->checkType=boost::get<string>(vars["checkType"]);
}
+ if(vars.count("mustResolve")) {
+ ret->mustResolve=boost::get<bool>(vars["mustResolve"]);
+ }
+
if(g_launchWork) {
g_launchWork->push_back([ret]() {
ret->tid = move(thread(responderThread, ret));
}
-DownstreamState::DownstreamState(const ComboAddress& remote_):
-checkName("a.root-servers.net."), checkType(QType::A)
+DownstreamState::DownstreamState(const ComboAddress& remote_): checkName("a.root-servers.net."), checkType(QType::A), mustResolve(false)
{
remote = remote_;
}
-bool upCheck(const ComboAddress& remote, const DNSName& checkName, const QType& checkType)
+bool upCheck(const ComboAddress& remote, const DNSName& checkName, const QType& checkType, bool mustResolve)
try
{
vector<uint8_t> packet;
return false;
if (responseHeader.rcode == RCode::ServFail)
return false;
+ if (mustResolve && (responseHeader.rcode == RCode::NXDomain || responseHeader.rcode == RCode::Refused))
+ return false;
// XXX fixme do bunch of checking here etc
return true;
for(auto& dss : g_dstates.getCopy()) { // this points to the actual shared_ptrs!
if(dss->availability==DownstreamState::Availability::Auto) {
- bool newState=upCheck(dss->remote, dss->checkName, dss->checkType);
+ bool newState=upCheck(dss->remote, dss->checkName, dss->checkType, dss->mustResolve);
if(newState != dss->upStatus) {
warnlog("Marking downstream %s as '%s'", dss->getName(), newState ? "up" : "down");
}
for(auto& dss : g_dstates.getCopy()) { // it is a copy, but the internal shared_ptrs are the real deal
if(dss->availability==DownstreamState::Availability::Auto) {
- bool newState=upCheck(dss->remote, dss->checkName, dss->checkType);
+ bool newState=upCheck(dss->remote, dss->checkName, dss->checkType, dss->mustResolve);
warnlog("Marking downstream %s as '%s'", dss->remote.toStringWithPort(), newState ? "up" : "down");
dss->upStatus = newState;
}