From 8fb39a38ca36a32cb487865853d3436341fed0b4 Mon Sep 17 00:00:00 2001 From: bert hubert Date: Wed, 23 Dec 2015 10:03:14 +0000 Subject: [PATCH] hook up localaddr and remoteaddr for lua API and use them in example script --- pdns/lua-recursor4.cc | 2 ++ pdns/powerdns-example-script.lua | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) 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")) -- 2.47.3