From 5d7327a3b0345489dcafc773ab5996b0199cbaef Mon Sep 17 00:00:00 2001 From: Kaarle Ritvanen Date: Thu, 13 Dec 2018 17:27:25 +0200 Subject: [PATCH] host.resolve: use drill --- awall/host.lua | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/awall/host.lua b/awall/host.lua index 84c67e3..bd44bd8 100644 --- a/awall/host.lua +++ b/awall/host.lua @@ -29,18 +29,14 @@ function M.resolve(host, context) if not dnscache[host] then dnscache[host] = {} - for rec in io.popen('dig '..host..' A '..host..' AAAA'):lines() do - local name, rtype, addr = - rec:match( - '^('..familypatterns.domain..')%s+%d+%s+IN%s+(A+)%s+(.+)' + for family, rtype in pairs{inet='A', inet6='AAAA'} do + for rec in io.popen('drill '..host..' '..rtype):lines() do + local name, addr = rec:match( + '^('..familypatterns.domain..')%s+%d+%s+IN%s+'..rtype.. + '%s+(.+)' ) - if name and name:sub(1, host:len() + 1) == host..'.' then - if rtype == 'A' then family = 'inet' - elseif rtype == 'AAAA' then family = 'inet6' - else family = nil end - - if family then + if name and name:sub(1, host:len() + 1) == host..'.' then assert(getfamily(addr, context) == family) table.insert(dnscache[host], {family, addr}) end -- GitLab