mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 12:20:41 +00:00
bugfix: dns parse hosts.conf
This commit is contained in:
@@ -119,23 +119,31 @@ 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+([^#;]+)")
|
||||||
local family = guess_name_type(ip)
|
if not ip or not hosts then
|
||||||
if hosts and family ~= "hostname" then
|
goto continue
|
||||||
for host in hosts:gmatch("%S+") do
|
|
||||||
host = host:lower()
|
|
||||||
local rt = rts[host]
|
|
||||||
if not rt then
|
|
||||||
rt = {}
|
|
||||||
rts[host] = rt
|
|
||||||
end
|
|
||||||
|
|
||||||
if not rt[family] then
|
|
||||||
rt[family] = {}
|
|
||||||
end
|
|
||||||
table.insert(rt[family], ip)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local family = guess_name_type(ip)
|
||||||
|
if family == "hostname" then
|
||||||
|
goto continue
|
||||||
|
end
|
||||||
|
|
||||||
|
for host in hosts:gmatch("%S+") do
|
||||||
|
host = host:lower()
|
||||||
|
local rt = rts[host]
|
||||||
|
if not rt then
|
||||||
|
rt = {}
|
||||||
|
rts[host] = rt
|
||||||
|
end
|
||||||
|
|
||||||
|
if not rt[family] then
|
||||||
|
rt[family] = {}
|
||||||
|
end
|
||||||
|
table.insert(rt[family], ip)
|
||||||
|
end
|
||||||
|
|
||||||
|
::continue::
|
||||||
end
|
end
|
||||||
return rts
|
return rts
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user