| 1 | function preresolve ( remoteip, domain, qtype ) |
|---|
| 2 | print ("prequery handler called for: ", remoteip, getlocaladdress(), domain, qtype) |
|---|
| 3 | pdnslog("a test message.. received query from "..remoteip.." on "..getlocaladdress()); |
|---|
| 4 | if domain == "www.powerdns.org." |
|---|
| 5 | then |
|---|
| 6 | ret={} |
|---|
| 7 | ret[1]= {qtype=pdns.A, content="85.17.220.215", ttl=86400} |
|---|
| 8 | print "dealing!" |
|---|
| 9 | return 0, ret |
|---|
| 10 | elseif domain == "www.baddomain.com." |
|---|
| 11 | then |
|---|
| 12 | print "dealing - faking nx" |
|---|
| 13 | return pdns.NXDOMAIN, {} |
|---|
| 14 | elseif domain == "echo." |
|---|
| 15 | then |
|---|
| 16 | print "dealing with echo!" |
|---|
| 17 | return 0, {{qtype=pdns.A, content=remoteip}} |
|---|
| 18 | elseif domain == "echo6." |
|---|
| 19 | then |
|---|
| 20 | print "dealing with echo6!" |
|---|
| 21 | return 0, {{qtype=pdns.AAAA, content=remoteip}} |
|---|
| 22 | else |
|---|
| 23 | print "not dealing!" |
|---|
| 24 | return -1, {} |
|---|
| 25 | end |
|---|
| 26 | end |
|---|
| 27 | |
|---|
| 28 | function nxdomain ( remoteip, domain, qtype ) |
|---|
| 29 | print ("nxhandler called for: ", remoteip, getlocaladdress(), domain, qtype, pdns.AAAA) |
|---|
| 30 | if qtype ~= pdns.A then return -1, {} end -- only A records |
|---|
| 31 | if not string.find(domain, "^www%.") then return -1, {} end -- only things that start with www. |
|---|
| 32 | |
|---|
| 33 | if matchnetmask(remoteip, {"127.0.0.1/32", "10.1.0.0/16"}) |
|---|
| 34 | then |
|---|
| 35 | print "dealing" |
|---|
| 36 | ret={} |
|---|
| 37 | ret[1]={qtype=pdns.CNAME, content="www.webserver.com", ttl=3602} |
|---|
| 38 | ret[2]={qname="www.webserver.com", qtype=pdns.A, content="1.2.3.4", ttl=3602} |
|---|
| 39 | ret[3]={qname="webserver.com", qtype=pdns.NS, content="ns1.webserver.com", place=2} |
|---|
| 40 | -- ret[1]={15, "25 ds9a.nl", 3602} |
|---|
| 41 | return 0, ret |
|---|
| 42 | else |
|---|
| 43 | print "not dealing" |
|---|
| 44 | return -1, ret |
|---|
| 45 | end |
|---|
| 46 | end |
|---|