Skip to content

Instantly share code, notes, and snippets.

@42wim
Last active November 6, 2020 10:02
Show Gist options
  • Save 42wim/e28709cc8548a36f34b7c090f1225a9e to your computer and use it in GitHub Desktop.
Save 42wim/e28709cc8548a36f34b7c090f1225a9e to your computer and use it in GitHub Desktop.
dnsdist
function maintenance()
res = blockingGetAddrInfo(newDNSName('mydns.service.consul'))
active = getPoolServers("apool")
local match = {}
local match2 = {}
for k,v in pairs(res) do
match[v:toString()]=false
end
for a,b in pairs(active) do
match2[a]=false
end
for a,b in pairs(active) do
for k,v in pairs(res) do
server = "[" .. v:toString() .. "]:53"
if server == b:getNameWithAddr() then
match[v:toString()]=true
end
end
end
for k,v in pairs(match) do
if v == false then
newServer({address=k,pool="apool"})
end
end
for k,v in pairs(match2) do
if v == false then
rmServer(k-1)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment