Skip to content

Commit

Permalink
Merge pull request #15032 from metajiji/patch-1
Browse files Browse the repository at this point in the history
dnsdist: Use getAddressInfo() instead python daemonized subprocess
  • Loading branch information
rgacogne authored Jan 16, 2025
2 parents dc542d0 + ab5fabe commit 45b9da6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 61 deletions.
4 changes: 1 addition & 3 deletions Dockerfile-dnsdist
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,9 @@ FROM debian:12-slim
RUN apt-get update && apt-get -y dist-upgrade && apt-get clean

# - python3 and jinja2 (for startup script)
# - python3-atomicwrites (for backend management)
# - tini (for signal management)
# - ca-certificates (for verifying downstream DoH/DoT certificates)
RUN apt-get install -y python3 python3-jinja2 python3-atomicwrites tini libcap2-bin ca-certificates && apt-get clean
RUN apt-get install -y python3 python3-jinja2 tini libcap2-bin ca-certificates && apt-get clean

# Output from builder
COPY --from=builder /build /
Expand Down Expand Up @@ -126,6 +125,5 @@ EXPOSE 8083/tcp
WORKDIR /etc/dnsdist

COPY dockerdata/dnsdist-resolver.lua /etc/dnsdist/
COPY dockerdata/dnsdist-resolver.py /usr/local/bin/dnsdist-resolver

ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/dnsdist-startup"]
25 changes: 10 additions & 15 deletions dockerdata/dnsdist-resolver.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down Expand Up @@ -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
Expand Down
43 changes: 0 additions & 43 deletions dockerdata/dnsdist-resolver.py

This file was deleted.

0 comments on commit 45b9da6

Please sign in to comment.