From: Bert Hubert Date: Mon, 23 Jun 2008 19:03:37 +0000 (+0000) Subject: Thanks #lua - to match on 'www.' in Lua, use 'www%.'. X-Git-Tag: rec-3.1.7.1~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=46f1066fb12bcc4b6d5478e945a24a32ea217f1d;p=thirdparty%2Fpdns.git Thanks #lua - to match on 'www.' in Lua, use 'www%.'. git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@1223 d19b8d6e-7fed-0310-83ef-9ca221ded41b --- diff --git a/pdns/docs/pdns.sgml b/pdns/docs/pdns.sgml index bdef81573a..98e46d9073 100644 --- a/pdns/docs/pdns.sgml +++ b/pdns/docs/pdns.sgml @@ -8253,7 +8253,7 @@ function nxdomain ( ip, domain, qtype ) ret={} if qtype ~= pdns.A then return -1, ret end -- only A records - if not string.find(domain, "^www.") then return -1, ret end -- only things that start with www. + if not string.find(domain, "^www%.") then return -1, ret end -- only things that start with www. if not matchnetmask(ip, "10.0.0.0/8", "192.168.0.0/16") then return -1, ret end -- only interfere with local queries ret[1]={qtype=pdns.A, content="127.1.2.3"} -- add IN A 127.1.2.3 ret[2]={qtype=pdns.A, content="127.3.2.1"} -- add IN A 127.3.2.1 @@ -8341,7 +8341,7 @@ end - Finally, the function matchnetmask(ip, netmask1, netmask2..) is available to match incoming queries against + Finally, the function matchnetmask(ip, netmask1, netmask2..) (or matchnetmask(ip, {netmask1, netmask2})) is available to match incoming queries against a number of netmasks. If any of these matches, the function returns true. diff --git a/pdns/powerdns-example-script.lua b/pdns/powerdns-example-script.lua index 98788f4d09..cb461d20d2 100644 --- a/pdns/powerdns-example-script.lua +++ b/pdns/powerdns-example-script.lua @@ -28,9 +28,9 @@ end function nxdomain ( ip, domain, qtype ) print ("nxhandler called for: ", ip, domain, qtype, pdns.AAAA) if qtype ~= pdns.A then return -1, {} end -- only A records - if not string.find(domain, "^www.") then return -1, {} end -- only things that start with www. + if not string.find(domain, "^www%.") then return -1, {} end -- only things that start with www. - if matchnetmask(ip, {"127.0.0.1/32", "10.1.0.0/16"}) -- , "192.168.0.0/16", "172.16.0.0/12", "::/0") + if matchnetmask(ip, {"127.0.0.1/32", "10.1.0.0/16"}) then print "dealing" ret={}