{
d_lw = new LuaContext;
d_lw->writeFunction("newDN", [](const std::string& dom){ return DNSName(dom); });
- d_lw->registerFunction("isPartOf", &DNSName::isPartOf);
+ d_lw->registerFunction("isPartOf", &DNSName::isPartOf);
+ d_lw->registerFunction<bool(DNSName::*)(const std::string&)>("equal",
+ [](const DNSName& lhs, const std::string& rhs) { return lhs==DNSName(rhs); });
+ d_lw->registerFunction("__eq", &DNSName::operator==);
+
d_lw->registerFunction<string(ComboAddress::*)()>("toString", [](const ComboAddress& ca) { return ca.toString(); });
d_lw->writeFunction("newCA", [](const std::string& a) { return ComboAddress(a); });
d_lw->writeFunction("newNMG", []() { return NetmaskGroup(); });
malwareset = newDS()
malwareset:add("nl")
+magic2 = newDN("www.magic2.com")
+
-- shows the various ways of blocking, dropping, changing questions
-- return false to say you did not take over the question, but we'll still listen to 'variable'
-- to selectively disable the cache
function preresolve(dq)
print("Got question for "..dq.qname:toString())
+
+ -- note that the comparisons below are CaSe InSensiTivE and you don't have to worry about trailing dots
+ if(dq.qname:equal("magic.com"))
+ then
+ print("Magic!")
+ else
+ print("not magic..")
+ end
+
+ if(dq.qname:__eq(magic2)) -- we hope to improve this syntax
+ then
+ print("Faster magic") -- compares against existing DNSName
+ end -- sadly, dq.qname == magic2 won't work yet
if blockset:check(dq.qname) then
dq.variable = true -- disable packet cache in any case