From: Peter van Dijk Date: Mon, 14 Sep 2020 12:24:14 +0000 (+0200) Subject: dnsdist dnsname: add toDNSString convenience function X-Git-Tag: rec-4.5.0-alpha0~8^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fdcc2d98cf4bd04bd9c7793e84c0d0e19c7014d2;p=thirdparty%2Fpdns.git dnsdist dnsname: add toDNSString convenience function --- diff --git a/pdns/dnsdist-lua-bindings.cc b/pdns/dnsdist-lua-bindings.cc index 62c679336b..2b348ac59e 100644 --- a/pdns/dnsdist-lua-bindings.cc +++ b/pdns/dnsdist-lua-bindings.cc @@ -219,6 +219,7 @@ void setupLuaBindings(LuaContext& luaCtx, bool client) luaCtx.registerFunction("wirelength", [](const DNSName& name) { return name.wirelength(); }); luaCtx.registerFunction("tostring", [](const DNSName&dn ) { return dn.toString(); }); luaCtx.registerFunction("toString", [](const DNSName&dn ) { return dn.toString(); }); + luaCtx.registerFunction("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(); }); diff --git a/pdns/dnsdistdist/docs/reference/dnsname.rst b/pdns/dnsdistdist/docs/reference/dnsname.rst index 4070fc61eb..38e66c6c27 100644 --- a/pdns/dnsdistdist/docs/reference/dnsname.rst +++ b/pdns/dnsdistdist/docs/reference/dnsname.rst @@ -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 diff --git a/pdns/dnsdistdist/docs/rules-actions.rst b/pdns/dnsdistdist/docs/rules-actions.rst index f1b32adde2..2d5055c71f 100644 --- a/pdns/dnsdistdist/docs/rules-actions.rst +++ b/pdns/dnsdistdist/docs/rules-actions.rst @@ -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.