Hello Peter,<br>I have solved it, after several minutes learning lua syntax, and examining pdns_recursor.cc, <br><br>1 function nodata (remoteip, domain, qtype, records)<br>2 print("nodata : ", remoteip, domain, qtype, records)<br>
<div class="im">3 if qtype ~= pdns.AAAA then return -1,{} end<br></div>4 setvariable()<br>5 return getFakeAAAARecords (domain, "0:0:0:0:0:ffff:0:0")<br>
6 end<br><br>I modified line 6 to<br><b>return getFakeAAAARecords (domain, "0:0:0:0:0:ffff:0:0")<br></b>previously:<br>return "getFakeAAAARecords, domain, "0:0:0:0:0:ffff:0:0"<br><br>I suggest minor correction at powerdns-example-script.lua as above<br>
<a href="http://wiki.powerdns.com/trac/browser/trunk/pdns/pdns/powerdns-example-script.lua">http://wiki.powerdns.com/trac/browser/trunk/pdns/pdns/powerdns-example-script.lua</a><br><br>Regards,<br>Muntasir<br><br><div class="gmail_quote">
On Fri, May 4, 2012 at 7:55 PM, Muntasir Rahman <span dir="ltr"><<a href="mailto:muntasir.rahman@gmail.com" target="_blank">muntasir.rahman@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello Peter,<br>Thanks for the clue. I have tried it. But, it return an error message like this: PANIC: unprotected error in call to Lua API.<br><br>I download the source, with lua hook to nodata function from here:<br><a href="http://svn.powerdns.com/snapshots/pdns-recursor-3.3-hooks.tar.bz2" target="_blank">http://svn.powerdns.com/snapshots/pdns-recursor-3.3-hooks.tar.bz2</a><br>
<br>i compile & run it using these steps:<br>$ LUA=1 ./configure<br>$ LUA=1 make<br>./pdns_recursor --local-address=0.0.0.0 --local-port=5300 --daemon=no --socket-dir=./ --lua-dns-script=dns64.lua<br><br>Here is the lua script (copy-paste from <a href="http://wiki.powerdns.com/trac/browser/trunk/pdns/pdns/powerdns-example-script.lua" target="_blank">http://wiki.powerdns.com/trac/browser/trunk/pdns/pdns/powerdns-example-script.lua</a>):<br>
<br>function nodata (remoteip, domain, qtype, records)<br> print("nodata : ", remoteip, domain, qtype, records)<div class="im"><br> if qtype ~= pdns.AAAA then return -1,{} end<br></div> setvariable()<br>
return "getFakeAAAARecords", domain, "0:0:0:0:0:ffff:0:0"<br>
end<br><br>At a terminal, i launch this command:<br>dig @<a href="http://127.0.0.1" target="_blank">127.0.0.1</a> -p 5300 <a href="http://www.kame.com" target="_blank">www.kame.com</a> AAAA<br><br>Aand i got this error message at recursor's terminal:<br>
PANIC: unprotected error in call to Lua API (attempt to index a nil value)<br><br>Would you like to give me a hint on what is wrong with the script?<br><br>Regards,<br>Muntasir<div class="HOEnZb"><div class="h5"><br><br>
<div class="gmail_quote">On Fri, May 4, 2012 at 5:42 PM, Peter van Dijk <span dir="ltr"><<a href="mailto:peter.van.dijk@netherlabs.nl" target="_blank">peter.van.dijk@netherlabs.nl</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello Muntasir,<br>
<div><br>
On May 4, 2012, at 6:47 , Muntasir Rahman wrote:<br>
<br>
> function nodata ( remoteip, domain, qtype, records )<br>
> print ("nodata called for: ", remoteip, getlocaladdress(), domain, qtype)<br>
> if qtype ~= pdns.AAAA then return -1, {} end -- only AAAA records<br>
> setvariable()<br>
> return "getFakeAAAARecords", domain, "fe80::21b:77ff:0:0" -- here i need to return ::ffff:ipv4.dotted.decimal.format<br>
> end<br>
><br>
> I would like to do something like this<br>
><br>
> ipv4 = "1.2.3.4" -- how do i get this data from recursor ???<br>
> ipv6 = "::ffff:" .. ipv4 -- synthesized representation of IPv4 in IPv6<br>
> return "getFakeAAARecords", domain, ipv6<br>
><br>
> My question is:<br>
> - how do i get IPv4 data using lua API in above script examples?<br>
<br>
</div>You don't. getFakeAAAARecords handles this. Just returning "getFakeAAAARecords", domain, "0:0:0:0:0:ffff:0:0" should work.<br>
<br>
(You can't say "::ffff" or "::ffff:" - the first would cause the v4 address to just overwrite those bits and the last would be a parse error).<br>
<br>
Kind regards,<br>
<span><font color="#888888">--<br>
Peter van Dijk<br>
Netherlabs Computer Consulting BV - <a href="http://www.netherlabs.nl/" target="_blank">http://www.netherlabs.nl/</a><br>
<br>
_______________________________________________<br>
Pdns-dev mailing list<br>
<a href="mailto:Pdns-dev@mailman.powerdns.com" target="_blank">Pdns-dev@mailman.powerdns.com</a><br>
<a href="http://mailman.powerdns.com/mailman/listinfo/pdns-dev" target="_blank">http://mailman.powerdns.com/mailman/listinfo/pdns-dev</a><br>
</font></span></blockquote></div><br>
</div></div></blockquote></div><br>