in kong/kong/resty/dns/utils.lua [152:196]
_M.parseResolvConf = function(filename)
local lines
if type(filename) == "table" then
lines = filename
else
local err
lines, err = utils.readlines(filename or _M.DEFAULT_RESOLV_CONF)
if not lines then return lines, err end
end
local result = {}
for _,line in ipairs(lines) do
local data, _ = line:match(PATT_COMMENT)
if data then
local option, details = data:match("^%s*(%a+)%s+(.-)%s*$")
if option == "nameserver" then
result.nameserver = result.nameserver or {}
if #result.nameserver < _M.MAXNS then
tinsert(result.nameserver, details:lower())
end
elseif option == "domain" then
result.search = nil
result.domain = details:lower()
elseif option == "search" then
result.domain = nil
local search = {}
result.search = search
for host in details:gmatch("%S+") do
if #search < _M.MAXSEARCH then
tinsert(search, host:lower())
end
end
elseif option == "sortlist" then
local list = {}
result.sortlist = list
for ips in details:gmatch("%S+") do
tinsert(list, ips)
end
elseif option == "options" then
result.options = result.options or {}
parseOption(result.options, details)
end
end
end
return result
end