Guest User

Untitled

a guest
Dec 18th, 2013
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. #recursor.conf
  2.  
  3. allow-from=0.0.0.0/0
  4. dont-query=
  5. local-address=0.0.0.0
  6. local-port=53
  7. quiet=yes
  8. setgid=pdns
  9. setuid=pdns
  10. lua-dns-script=/usr/local/bin/rec.lua
  11.  
  12. # rec.lua
  13.  
  14. function preresolve ( ip, domain, qtype )
  15.  
  16. --- require "luasql.mysql"
  17. --- env = assert(luasql.mysql())
  18. --- conn = assert(env:connect("powerdns", "powerdns", "fL3Su54vtO", "localhost"))
  19. --- conn:setautocommit(true)
  20.  
  21.  
  22. require "luasql.postgres"
  23. env = assert (luasql.postgres())
  24. conn = assert(env:connect("pdns","pdns","dFIC7krpxK","localhost"))
  25.  
  26.  
  27. function rows (connection, sql_statement)
  28. local cursor = assert (connection:execute (sql_statement))
  29. return function ()
  30. return cursor:fetch()
  31. end
  32. end
  33.  
  34. --- domain="google.com"
  35. --- ip="127.0.0.1"
  36.  
  37. --- query="select count(domain) as count from domains where concat(domain,'.')='"..domain.."' and email=(select IFNULL((select email from clients where ip='"..ip.."'),'[email protected]'))"
  38. --- query="select count(domain) as count from domains where domain||'.'='"..domain.."' and email=(select email from clients where ip='"..ip.."')"
  39. --- query="select count(domain) as count from domains where domain||'.'='"..domain.."' and email=(select COALESCE((select email from clients where ip='"..ip.."'),'[email protected]'))"
  40. query="select count(domain) as count from domains where domain||'.'='"..domain.."' and (email=(select email from clients where ip='"..ip.."') or email='[email protected]')"
  41.  
  42. print (string.format ("%s", query))
  43.  
  44. for count in rows (conn, query) do
  45. if count == "0"
  46. then return 0, {{qtype=pdns.A, content="12.12.12.12"}}
  47. else return -1
  48. end
  49.  
  50. end
  51.  
  52.  
  53. end
  54. function nxdomain ( ip, destination, domain, qtype )
  55. return 3, {}
  56. end
Advertisement
Add Comment
Please, Sign In to add comment