[dnsdist] addMasks() or addMasksFromFile() to make dealing with multiple addresses easier ?

scott McGillivray floriangray at mail.com
Thu Jun 1 01:40:01 UTC 2017


Hi

I want to use addMask() but i have 80+ /32 addresses that i need to add which means i have the matching number of lines like this

v = newNMG()
v:addMask("x.x.x.x/32")
v:addMask("x.x.x.x/32")
v:addMask("x.x.x.x/32")
v:addMask("x.x.x.x/32")
...


I was wondering if addMasks() would be a good addition ? So it would be like this.. 

v:addMask("x.x.x.x/32", "x.x.x.x/32", "x.x.x.x/32", "x.x.x.x/32", "x.x.x.x/32", "x.x.x.x/32", "x.x.x.x/32")

Or even addMasksFromFile() so the addresses could be populated more easily from external source ?


At the moment i added some Lua to the dnsdist.conf so i load the list of addresses from an external file. For me this file is managed by Chef but seems kind of clunky and doesn't really reduce the config size which was my original goal.

local open = io.open

local function read_file(path)
    local file = open(path, "rb")
    if not file then return nil end

    local lines = {}
    for line in file:lines() do
      if line ~= nil and line ~= '' then
        table.insert (lines, line)
      end
    end

    file:close()
    return lines
end

local whitelist = read_file("/etc/dnsdist/rd_whitelist");

rd_whitelist = newNMG()

if whitelist ~= nil and next(whitelist) ~= nil then
  for _,line in pairs(whitelist) do
    rd_whitelist:addMask(line)
  end
end


thanks.



More information about the dnsdist mailing list