Software /
code /
prosody
Comparison
net/resolvers/basic.lua @ 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 |
parent | 10485:913276ba0c47 |
child | 10624:0725b7b8dc14 |
comparison
equal
deleted
inserted
replaced
10620:09d98cd38fe2 | 10621:e5ab31845094 |
---|---|
40 self:next(cb); | 40 self:next(cb); |
41 end | 41 end |
42 | 42 |
43 -- Resolve DNS to target list | 43 -- Resolve DNS to target list |
44 local dns_resolver = adns.resolver(); | 44 local dns_resolver = adns.resolver(); |
45 dns_resolver:lookup(function (answer) | 45 |
46 if answer then | 46 if self.connector_options.use_ipv4 ~= false then |
47 for _, record in ipairs(answer) do | 47 dns_resolver:lookup(function (answer) |
48 table.insert(targets, { self.conn_type.."4", record.a, self.port, self.extra }); | 48 if answer then |
49 for _, record in ipairs(answer) do | |
50 table.insert(targets, { self.conn_type.."4", record.a, self.port, self.extra }); | |
51 end | |
49 end | 52 end |
50 end | 53 ready(); |
51 ready(); | 54 end, self.hostname, "A", "IN"); |
52 end, self.hostname, "A", "IN"); | 55 end |
53 | 56 |
54 dns_resolver:lookup(function (answer) | 57 if self.connector_options.use_ipv6 ~= false then |
55 if answer then | 58 dns_resolver:lookup(function (answer) |
56 for _, record in ipairs(answer) do | 59 if answer then |
57 table.insert(targets, { self.conn_type.."6", record.aaaa, self.port, self.extra }); | 60 for _, record in ipairs(answer) do |
61 table.insert(targets, { self.conn_type.."6", record.aaaa, self.port, self.extra }); | |
62 end | |
58 end | 63 end |
59 end | 64 ready(); |
60 ready(); | 65 end, self.hostname, "AAAA", "IN"); |
61 end, self.hostname, "AAAA", "IN"); | 66 end |
62 end | 67 end |
63 | 68 |
64 local function new(hostname, port, conn_type, extra) | 69 local function new(hostname, port, conn_type, extra) |
65 local ascii_host = idna_to_ascii(hostname); | 70 local ascii_host = idna_to_ascii(hostname); |
66 local targets = nil; | 71 local targets = nil; |