TCPNameserver *TN;
static vector<DNSDistributor*> g_distributors;
vector<std::shared_ptr<UDPNameserver> > g_udpReceivers;
-AuthLua *LPE;
ArgvMap &arg()
{
::arg().set("lua-prequery-script", "Lua script with prequery handler (DO NOT USE)")="";
::arg().set("lua-dnsupdate-policy-script", "Lua script with DNS update policy handler")="";
- ::arg().set("experimental-lua-policy-script", "Lua script for the policy engine")="";
::arg().setSwitch("traceback-handler","Enable the traceback handler (Linux only)")="yes";
::arg().setSwitch("direct-dnskey","Fetch DNSKEY RRs from backend during DNSKEY synthesis")="no";
cached.d.rd=P->d.rd; // copy in recursion desired bit
cached.d.id=P->d.id;
cached.commitD(); // commit d to the packet inlined
-
- int policyres = PolicyDecision::PASS;
- if(LPE)
- {
- // FIXME: cached does not have qdomainwild/qdomainzone because packetcache entries
- // go through tostring/noparse
- policyres = LPE->police(&question, &cached);
- }
-
- if (policyres == PolicyDecision::PASS) {
- NS->send(&cached); // answer it then inlined
- diff=P->d_dt.udiff();
- avg_latency=(int)(0.999*avg_latency+0.001*diff); // 'EWMA'
- }
- // FIXME implement truncate
-
+ NS->send(&cached); // answer it then inlined
+ diff=P->d_dt.udiff();
+ avg_latency=(int)(0.999*avg_latency+0.001*diff); // 'EWMA'
continue;
}
}
if(::arg().mustDo("slave") || ::arg().mustDo("master") || !::arg()["forward-notify"].empty())
Communicator.go();
- if(!::arg()["experimental-lua-policy-script"].empty()){
- LPE=new AuthLua(::arg()["experimental-lua-policy-script"]);
- L<<Logger::Warning<<"Loaded Lua policy script "<<::arg()["experimental-lua-policy-script"]<<endl;
- }
-
if(TN)
TN->go(); // tcp nameserver launch
extern vector<std::shared_ptr<UDPNameserver> > g_udpReceivers;
extern int avg_latency;
extern TCPNameserver *TN;
-extern AuthLua *LPE;
extern ArgvMap & arg( void );
extern void declareArguments();
extern void declareStats();
d_rawpacket.assign((char*)&packet[0], packet.size()); // XXX we could do this natively on a vector..
- // copy RR counts so LPE can read them
+ // copy RR counts so they can be read later
d.qdcount = pw.getHeader()->qdcount;
d.ancount = pw.getHeader()->ancount;
d.nscount = pw.getHeader()->nscount;
return ret.str();
}
-string DLPolicy(const vector<string>&parts, Utility::pid_t ppid)
-{
- if(LPE) {
- return LPE->policycmd(parts);
- }
- else {
- return "no policy script loaded";
- }
-}
-
#ifdef HAVE_P11KIT1
extern bool PKCS11ModuleSlotLogin(const std::string& module, const string& tokenId, const std::string& pin);
#endif
string DLNotifyRetrieveHandler(const vector<string>&parts, Utility::pid_t ppid);
string DLCurrentConfigHandler(const vector<string>&parts, Utility::pid_t ppid);
string DLListZones(const vector<string>&parts, Utility::pid_t ppid);
-string DLPolicy(const vector<string>&parts, Utility::pid_t ppid);
string DLTokenLogin(const vector<string>&parts, Utility::pid_t ppid);
uint64_t udpErrorStats(const std::string& str);
#endif /* PDNS_DYNHANDLER_HH */
DNSPacket *PacketHandler::question(DNSPacket *p)
{
DNSPacket *ret;
- int policyres = PolicyDecision::PASS;
if(d_pdl)
{
rdqueries++;
}
- if(LPE)
- {
- policyres = LPE->police(p, NULL);
- }
-
- if (policyres == PolicyDecision::DROP)
- return NULL;
-
- if (policyres == PolicyDecision::TRUNCATE) {
- ret=p->replyPacket(); // generate an empty reply packet
- ret->d.tc = 1;
- ret->commitD();
- return ret;
- }
-
- ret=doQuestion(p);
-
- if(LPE) {
- policyres = LPE->police(p, ret);
- if(policyres == PolicyDecision::DROP) {
- delete ret;
- return NULL;
- }
- if (policyres == PolicyDecision::TRUNCATE) {
- delete ret;
- ret=p->replyPacket(); // generate an empty reply packet
- ret->d.tc = 1;
- ret->commitD();
- }
-
- }
- return ret;
+ return doQuestion(p);
}
DynListener::registerFunc("RETRIEVE",&DLNotifyRetrieveHandler, "retrieve slave domain", "<domain>");
DynListener::registerFunc("CURRENT-CONFIG",&DLCurrentConfigHandler, "retrieve the current configuration");
DynListener::registerFunc("LIST-ZONES",&DLListZones, "show list of zones", "[master|slave|native]");
- DynListener::registerFunc("POLICY",&DLPolicy, "interact with policy engine", "[policy command]");
DynListener::registerFunc("TOKEN-LOGIN", &DLTokenLogin, "Login to a PKCS#11 token", "<module> <slot> <pin>");
if(!::arg()["tcp-control-address"].empty()) {
cached->d.rd=packet->d.rd; // copy in recursion desired bit
cached->commitD(); // commit d to the packet inlined
- if(LPE) LPE->police(&(*packet), &(*cached), true);
-
sendPacket(cached, fd); // presigned, don't do it again
continue;
}
}
reply=shared_ptr<DNSPacket>(s_P->doQuestion(packet.get())); // we really need to ask the backend :-)
-
- if(LPE) LPE->police(&(*packet), &(*reply), true);
}
if(!reply) // unable to write an answer?