bugfix: dns parse hosts.conf

This commit is contained in:
xjdrew
2019-03-28 14:26:23 +08:00
committed by 云风
parent 305a29d885
commit ee1f5055ea

View File

@@ -119,9 +119,16 @@ local function parse_hosts()
local rts = {} local rts = {}
for line in f:lines() do for line in f:lines() do
local ip, hosts = string.match(line, "^%s*([%[%]%x%.%:]+)%s+([^#;]*)") local ip, hosts = string.match(line, "^%s*([%[%]%x%.%:]+)%s+([^#;]+)")
if not ip or not hosts then
goto continue
end
local family = guess_name_type(ip) local family = guess_name_type(ip)
if hosts and family ~= "hostname" then if family == "hostname" then
goto continue
end
for host in hosts:gmatch("%S+") do for host in hosts:gmatch("%S+") do
host = host:lower() host = host:lower()
local rt = rts[host] local rt = rts[host]
@@ -135,7 +142,8 @@ local function parse_hosts()
end end
table.insert(rt[family], ip) table.insert(rt[family], ip)
end end
end
::continue::
end end
return rts return rts
end end