Lua preresolve doesn't for cached answers?

classic Classic list List threaded Threaded
1 message Options
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Lua preresolve doesn't for cached answers?

gowen
This post has NOT been accepted by the mailing list yet.
I am writing a Lua script to inspect queries as they come into pdns-recursor.  However, it seems that only queries which are not cached trigger the preresolve() function.  Here's a dead-simple lua script:

function preresolve ( remoteip, domain, qtype )
    pdnslog("In preresolve for "..domain);
    return pdns.PASS, {}
end

The following sequence of commands (output, which was normal, trimmed):

$ host -t A cnn.com 127.0.0.1
$ host -t A cnn.com 127.0.0.1
$ host -t A cnn.com 127.0.0.1
$ host -t A yahoo.com 127.0.0.1
$ host -t A yahoo.com 127.0.0.1
$ host -t A yahoo.com 127.0.0.1

Only results in the following being logged:

Apr 17 21:28:54 sonic pdns_recursor[17538]: From Lua script: In preresolve for cnn.com.
Apr 17 21:29:06 sonic pdns_recursor[17538]: From Lua script: In preresolve for yahoo.com.

The obvious assumption - which I've been unable to correlate with online documentation or via searching the mailing list - is that preresolve() is only called if the query doesn't have a cached answer.  Is that true?  If so, is there any way to act upon queries before "resolution" whether or not they're cached?  I could repeat my test logic in postresolve() but it seems unhappy to duplicate the effort (and it must be done in preresolve() in order to alter events before resolving queries are made by the recursor).

I'm running pdns-recursor 3.7.3 as installed by Yum on CentOS 7, which comes with 3.4.8 of pdns and pdns-backend-lua:

# rpm -qa | grep pdns
pdns-recursor-3.7.3-1.el7.x86_64
pdns-backend-lua-3.4.8-1.el7.x86_64
pdns-3.4.8-1.el7.x86_64

Any help appreciated.

Thanks,
gowen
Loading...