}
return stats;
});
+
+ luaCtx.registerFunction<LuaArray<DNSName>(std::shared_ptr<DNSDistPacketCache>::*)(const ComboAddress& addr)const>("getDomainListByAddress", [](const std::shared_ptr<DNSDistPacketCache>& cache, const ComboAddress& addr) {
+ LuaArray<DNSName> results;
+ if (!cache) {
+ return results;
+ }
+
+ int counter = 1;
+ auto domains = cache->getDomainsContainingRecords(addr);
+ results.reserve(domains.size());
+ for (auto& domain : domains) {
+ results.emplace_back(counter, std::move(domain));
+ counter++;
+ }
+ return results;
+ });
+
+ luaCtx.registerFunction<LuaArray<ComboAddress>(std::shared_ptr<DNSDistPacketCache>::*)(const DNSName& domain)const>("getAddressListByDomain", [](const std::shared_ptr<DNSDistPacketCache>& cache, const DNSName& domain) {
+ LuaArray<ComboAddress> results;
+ if (!cache) {
+ return results;
+ }
+
+ int counter = 1;
+ auto addresses = cache->getRecordsForDomain(domain);
+ results.reserve(addresses.size());
+ for (auto& address : addresses) {
+ results.emplace_back(counter, std::move(address));
+ counter++;
+ }
+ return results;
+ });
+
luaCtx.registerFunction<void(std::shared_ptr<DNSDistPacketCache>::*)(const std::string& fname)const>("dump", [](const std::shared_ptr<DNSDistPacketCache>& cache, const std::string& fname) {
if (cache) {
:param int qtype: The type to expunge, can be a pre-defined :ref:`DNSQType`
:param bool suffixMatch: When set to true, remove all entries under ``name``
+ .. method:: PacketCache:getAddressListByDomain(domain)
+
+ .. versionadded:: 1.8.0
+
+ This method looks up the answers present in the cache for the supplied domain, and returns the list of addresses present in the answer section of these answers (in A records for IPv4 addresses, and AAAA records for IPv6 ones). The addresses are returned as a list of :class:`ComboAddress` objects.
+
+ :param DNSName domain: The domain to look for
+
+ .. method:: PacketCache:getDomainListByAddress(addr)
+
+ .. versionadded:: 1.8.0
+
+ Return a list of domains, as :class:`DNSName` objects, for which an answer is present in the cache and has a corresponding A record (for IPv4 addresses) or AAAA record (for IPv6 addresses) in the answer section.
+
+ :param ComboAddress addr: The address to look for
+
.. method:: PacketCache:getStats()
.. versionadded:: 1.4.0