]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Update dnsdist-resolver.lua 15032/head
authorDenis Kadyshev <metajiji@gmail.com>
Mon, 13 Jan 2025 11:54:35 +0000 (18:54 +0700)
committerGitHub <noreply@github.com>
Mon, 13 Jan 2025 11:54:35 +0000 (18:54 +0700)
dockerdata/dnsdist-resolver.lua

index 89e24b319e6e0640fd58d81653b06234b57115ba..f9bf8d1c3c04b867de443ef7be80b57081568490 100644 (file)
@@ -17,7 +17,15 @@ _M.verbose = false
 local ourservers = {}
 local ourcount = {}
 
-local resolverpipe = io.popen('/usr/local/bin/dnsdist-resolver', 'w')
+-- Global variable for store results for getAddressInfo() function
+local resout = {}
+
+local function resolveCB(hostname, ips)
+    resout[hostname] = {}
+    for _, ip in ipairs(ips) do
+        table.insert(resout[hostname], ip:toString())
+    end
+end
 
 local function tablecopy(t)
     local t2 = {}
@@ -71,22 +79,9 @@ local function setServer(name, ip)
 end
 
 function _M.maintenance()
-    -- TODO: only do this if the list has changed
-    -- TODO: check return values
     for k in pairs(_M.servers) do
-        resolverpipe:write(k .. ' ')
+        getAddressInfo(k, resolveCB)
     end
-    resolverpipe:write('\n')
-    resolverpipe:flush()
-
-    -- TODO: maybe this failure should be quiet for the first X seconds?
-    local ret, resout = pcall(loadfile, '/tmp/dnsdist-resolver.out')
-    if not ret then
-        error(resout)
-    end
-
-    -- on purpose no pcall, an error here is a bug
-    resout = resout()
 
     local activeservers = {}
     -- check for servers removed by controller