kpcyrd/dns-resolve
function run(arg)
records = dns(arg['value'], 'A')
if last_err() then return end
resolvable = records['error'] == nil
if arg['resolvable'] ~= resolvable then
db_update('subdomain', arg, {
resolvable=resolvable
})
end
if not resolvable then
return
end
records = records['answers']
for i=1, #records do
r = records[i][2]
if r['A'] ~= nil then
ipaddr_id = db_add('ipaddr', {
family='4',
value=r['A'],
})
if last_err() then return end
db_add('subdomain-ipaddr', {
subdomain_id=arg['id'],
ip_addr_id=ipaddr_id,
})
if last_err() then return end
end
end
end