Permalink
Browse files

add getregisteredname() function for recursor Lua scripts

  • Loading branch information...
1 parent cd6310a commit 8cd4851beb78bc6ab320926fb5cb6a09282016b1 @Habbie Habbie committed with Habbie Feb 6, 2015
Showing with 15 additions and 1 deletion.
  1. +1 −0 docs/markdown/changelog.md.raw
  2. +4 −0 docs/markdown/recursor/scripting.md
  3. +10 −1 pdns/lua-recursor.cc
@@ -111,6 +111,7 @@ New features:
- Lua preoutquery filter 3457a2a0ec41d3b3aff7640f30008788e1228a6e
- Lua IP-based filter (ipfilter) before parsing packets 4ea949413c495254acb0bd19335142761c1efc0c
- `iputils` class for Lua, to quickly process IP addresses and netmasks in their native format
+- `getregisteredname` function for Lua, to find the registered domain for a given name
- Various new ringbuffers: top-servfail-remotes, top-largeanswer-remotes, top-servfail-queries
Speedups:
@@ -180,6 +180,10 @@ In `preoutquery`, `getlocaladdress()` returns the address of the client that cau
To indicate that an answer should not be cached in the packet cache, use
`setvariable()`. Available since version 3.3.
+`getregisteredname('www.powerdns.com')` returns `powerdns.com.`, based on Mozilla's
+Public Suffix List. In general it will tell you the 'registered domain' for a given
+name.
+
To get fake AAAA records for DNS64 usage, use `return "getFakeAAAARecords",
domain, "fe80::21b:77ff:0:0"`. Available since version 3.4.
View
@@ -61,11 +61,20 @@ extern "C" {
#include <boost/foreach.hpp>
#include "logger.hh"
#include "namespaces.hh"
+#include "rec_channel.hh"
+
+static int getRegisteredNameLua(lua_State *L) {
+ const char *name = luaL_checkstring(L, 1);
+ string regname=getRegisteredName(name);
+ lua_pushstring(L, regname.c_str());
+ return 1;
+}
RecursorLua::RecursorLua(const std::string &fname)
: PowerDNSLua(fname)
{
- // empty
+ lua_pushcfunction(d_lua, getRegisteredNameLua);
+ lua_setglobal(d_lua, "getregisteredname");
}
int followCNAMERecords(vector<DNSResourceRecord>& ret, const QType& qtype)

0 comments on commit 8cd4851

Please sign in to comment.