mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 20:23:06 +00:00
bugfix: dns parse hosts.conf
This commit is contained in:
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user