luaCtx.registerFunction<size_t(DNSName::*)()const>("wirelength", [](const DNSName& name) { return name.wirelength(); });
luaCtx.registerFunction<string(DNSName::*)()const>("tostring", [](const DNSName&dn ) { return dn.toString(); });
luaCtx.registerFunction<string(DNSName::*)()const>("toString", [](const DNSName&dn ) { return dn.toString(); });
+ luaCtx.registerFunction<string(DNSName::*)()const>("toStringNoDot", [](const DNSName&dn ) { return dn.toStringNoDot(); });
luaCtx.registerFunction<string(DNSName::*)()const>("__tostring", [](const DNSName&dn ) { return dn.toString(); });
luaCtx.registerFunction<string(DNSName::*)()const>("toDNSString", [](const DNSName&dn ) { return dn.toDNSString(); });
+ luaCtx.registerFunction<DNSName(DNSName::*)(const DNSName&)const>("makeRelative", [](const DNSName& dn, const DNSName& to) { return dn.makeRelative(to); });
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(); });
}
});
- luaCtx.registerFunction("check",(bool (SuffixMatchNode::*)(const DNSName&) const) &SuffixMatchNode::check);
+ luaCtx.registerFunction("check", (bool (SuffixMatchNode::*)(const DNSName&) const) &SuffixMatchNode::check);
+ luaCtx.registerFunction<boost::optional<DNSName> (SuffixMatchNode::*)(const DNSName&) const>("getBestMatch", [](const SuffixMatchNode& smn, const DNSName& needle) {
+ boost::optional<DNSName> result{boost::none};
+ auto res = smn.getBestMatch(needle);
+ if (res) {
+ result = *res;
+ }
+ return result;
+ });
#endif /* DISABLE_SUFFIX_MATCH_BINDINGS */
#ifndef DISABLE_NETMASK_BINDINGS
:param string name: The suffix to add to the set.
:param table name: The suffixes to add to the set. Elements of the table should be of the same type, either DNSName or string.
+ .. method:: SuffixMatchNode:check(name) -> bool
+
+ Return true if the given name is a sub-domain of one of those in the set, and false otherwise.
+
+ :param DNSName name: The name to test against the set.
+
+ .. method:: SuffixMatchNode:getBestMatch(name) -> DNSName
+
+ .. versionadded:: 1.8.0
+
+ Returns the best match for the supplied name, or nil if there was no match.
+
+ :param DNSName name: The name to look up.
+
.. method:: SuffixMatchNode:remove(name)
.. versionadded:: 1.5.0
:param string name: The suffix to remove from the set.
:param table name: The suffixes to remove from the set. Elements of the table should be of the same type, either DNSName or string.
- .. method:: SuffixMatchNode:check(name) -> bool
-
- Return true if the given name is a sub-domain of one of those in the set, and false otherwise.
-
- :param DNSName name: The name to test against the set.
-
Outgoing TLS tickets cache management
-------------------------------------
:param DNSName name: The name to check against
+ .. method:: DNSName:makeRelative(name) -> DNSName
+
+ .. versionadded:: 1.8.0
+
+ Provided that the current name is part of the supplied name, returns a new DNSName
+ composed only of the labels that are below the supplied name (ie making www.powerdns.com
+ relative to powerdns.com would return only wwww)
+ Otherwise an empty (unset) DNSName is returned.
+
+ :param DNSName name: The name to make us relative against
+
.. method:: DNSName:toDNSString() -> string
Returns a wire format form of the DNSName, suitable for usage in :func:`SpoofRawAction`.
Returns a human-readable form of the DNSName.
+ .. method:: DNSName:toStringNoDot() -> string
+
+ .. versionadded:: 1.8.0
+
+ Returns a human-readable form of the DNSName, without the trailing dot.
+
.. method:: DNSName:wirelength() -> int
Returns the length in bytes of the DNSName as it would be on the wire.