]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist dnsname: add toDNSString convenience function 9466/head
authorPeter van Dijk <peter.van.dijk@powerdns.com>
Mon, 14 Sep 2020 12:24:14 +0000 (14:24 +0200)
committerPeter van Dijk <peter.van.dijk@powerdns.com>
Mon, 14 Sep 2020 12:24:14 +0000 (14:24 +0200)
pdns/dnsdist-lua-bindings.cc
pdns/dnsdistdist/docs/reference/dnsname.rst
pdns/dnsdistdist/docs/rules-actions.rst

index 62c679336bec7f7a08064d4a90c7f6846c999a9d..2b348ac59e78ce93d4d985151bd20f025ee6510d 100644 (file)
@@ -219,6 +219,7 @@ void setupLuaBindings(LuaContext& luaCtx, bool client)
   luaCtx.registerFunction<size_t(DNSName::*)()>("wirelength", [](const DNSName& name) { return name.wirelength(); });
   luaCtx.registerFunction<string(DNSName::*)()>("tostring", [](const DNSName&dn ) { return dn.toString(); });
   luaCtx.registerFunction<string(DNSName::*)()>("toString", [](const DNSName&dn ) { return dn.toString(); });
+  luaCtx.registerFunction<string(DNSName::*)()>("toDNSString", [](const DNSName&dn ) { return dn.toDNSString(); });
   luaCtx.writeFunction("newDNSName", [](const std::string& name) { return DNSName(name); });
   luaCtx.writeFunction("newDNSNameFromRaw", [](const std::string& name) { return DNSName(name.c_str(), name.size(), 0, false); });
   luaCtx.writeFunction("newSuffixMatchNode", []() { return SuffixMatchNode(); });
index 4070fc61eb2134f667fb629aca350478375402bd..38e66c6c273b59c361099b1fd99ab199eda505d7 100644 (file)
@@ -52,6 +52,10 @@ Functions and methods of a ``DNSName``
 
     :param DNSName name: The name to check against
 
+  .. method:: DNSName:toDNSString() -> string
+
+    Returns a wire format form of the DNSName, suitable for usage in :func:`SpoofRawAction`.
+
   .. method:: DNSName:toString() -> string
               DNSName:tostring() -> string
 
index f1b32adde22ed0f4717c71c429c4c356a19b0c97..2d5055c71ffeca28335177b6c16f593cce912a65 100644 (file)
@@ -1327,6 +1327,8 @@ The following actions exist.
     -- select reverse queries for '127.0.0.1' and answer with 'localhost'
     addAction(AndRule({QNameRule('1.0.0.127.in-addr.arpa.'), QTypeRule(DNSQType.PTR)}), SpoofRawAction("\009localhost\000"))
 
+  :func:`DNSName:toDNSString` is convenient for converting names to wire format for passing to ``SpoofRawAction``.
+
   :param string rawAnswer: The raw record data
   :param table options: A table with key: value pairs with options.