From: bert hubert Date: Wed, 23 Dec 2015 10:03:14 +0000 (+0000) Subject: hook up localaddr and remoteaddr for lua API and use them in example script X-Git-Tag: dnsdist-1.0.0-alpha1~19^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8fb39a38ca36a32cb487865853d3436341fed0b4;p=thirdparty%2Fpdns.git hook up localaddr and remoteaddr for lua API and use them in example script --- diff --git a/pdns/lua-recursor4.cc b/pdns/lua-recursor4.cc index ca08e838a1..4f4a6620c2 100644 --- a/pdns/lua-recursor4.cc +++ b/pdns/lua-recursor4.cc @@ -176,6 +176,8 @@ RecursorLua4::RecursorLua4(const std::string& fname) d_lw->registerFunction("toString", [](const DNSName&dn ) { return dn.toString(); }); d_lw->registerMember("qname", &DNSQuestion::qname); d_lw->registerMember("qtype", &DNSQuestion::qtype); + d_lw->registerMember("localaddr", &DNSQuestion::local); + d_lw->registerMember("remoteaddr", &DNSQuestion::remote); d_lw->registerMember("rcode", &DNSQuestion::rcode); d_lw->registerMember("variable", &DNSQuestion::variable); d_lw->registerMember("followupFunction", &DNSQuestion::followupFunction); diff --git a/pdns/powerdns-example-script.lua b/pdns/powerdns-example-script.lua index cda9e81c20..96825c9ffc 100644 --- a/pdns/powerdns-example-script.lua +++ b/pdns/powerdns-example-script.lua @@ -15,7 +15,7 @@ magic2 = newDN("www.magic2.com") -- 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()) + print("Got question for "..dq.qname:toString().." from "..dq.remoteaddr:toString().." to "..dq.localaddr: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"))