Software /
code /
prosody
Changeset
10621:e5ab31845094
net.resolvers.basic: Obey use_ipv4/use_ipv6
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 25 Jan 2020 14:03:30 +0000 |
parents | 10620:09d98cd38fe2 |
children | 10622:0662fe0e2c31 |
files | net/resolvers/basic.lua |
diffstat | 1 files changed, 20 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/net/resolvers/basic.lua Fri Jan 24 23:29:14 2020 +0100 +++ b/net/resolvers/basic.lua Sat Jan 25 14:03:30 2020 +0000 @@ -42,23 +42,28 @@ -- Resolve DNS to target list local dns_resolver = adns.resolver(); - dns_resolver:lookup(function (answer) - if answer then - for _, record in ipairs(answer) do - table.insert(targets, { self.conn_type.."4", record.a, self.port, self.extra }); - end - end - ready(); - end, self.hostname, "A", "IN"); - dns_resolver:lookup(function (answer) - if answer then - for _, record in ipairs(answer) do - table.insert(targets, { self.conn_type.."6", record.aaaa, self.port, self.extra }); + if self.connector_options.use_ipv4 ~= false then + dns_resolver:lookup(function (answer) + if answer then + for _, record in ipairs(answer) do + table.insert(targets, { self.conn_type.."4", record.a, self.port, self.extra }); + end end - end - ready(); - end, self.hostname, "AAAA", "IN"); + ready(); + end, self.hostname, "A", "IN"); + end + + if self.connector_options.use_ipv6 ~= false then + dns_resolver:lookup(function (answer) + if answer then + for _, record in ipairs(answer) do + table.insert(targets, { self.conn_type.."6", record.aaaa, self.port, self.extra }); + end + end + ready(); + end, self.hostname, "AAAA", "IN"); + end end local function new(hostname, port, conn_type, extra)