Software /
code /
prosody
Comparison
net/resolvers/basic.lua @ 10386:cf93a951da37
Merge 0.11->trunk
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 02 Nov 2019 19:38:12 +0100 |
parent | 9691:e11e076f0eb8 |
parent | 10385:62a7042e0771 |
child | 10401:1ef1f6c43c5b |
comparison
equal
deleted
inserted
replaced
10383:496248e48a1d | 10386:cf93a951da37 |
---|---|
1 local adns = require "net.adns"; | 1 local adns = require "net.adns"; |
2 local inet_pton = require "util.net".pton; | 2 local inet_pton = require "util.net".pton; |
3 local idna_to_ascii = require "util.encodings".idna.to_ascii; | |
3 local unpack = table.unpack or unpack; -- luacheck: ignore 113 | 4 local unpack = table.unpack or unpack; -- luacheck: ignore 113 |
4 | 5 |
5 local methods = {}; | 6 local methods = {}; |
6 local resolver_mt = { __index = methods }; | 7 local resolver_mt = { __index = methods }; |
7 | 8 |
14 return; | 15 return; |
15 end | 16 end |
16 local next_target = table.remove(self.targets, 1); | 17 local next_target = table.remove(self.targets, 1); |
17 cb(unpack(next_target, 1, 4)); | 18 cb(unpack(next_target, 1, 4)); |
18 return; | 19 return; |
20 end | |
21 | |
22 if not self.hostname then | |
23 -- FIXME report IDNA error | |
24 cb(nil); | |
19 end | 25 end |
20 | 26 |
21 local targets = {}; | 27 local targets = {}; |
22 local n = 2; | 28 local n = 2; |
23 local function ready() | 29 local function ready() |
58 end, self.hostname, "AAAA", "IN"); | 64 end, self.hostname, "AAAA", "IN"); |
59 end | 65 end |
60 | 66 |
61 local function new(hostname, port, conn_type, extra) | 67 local function new(hostname, port, conn_type, extra) |
62 return setmetatable({ | 68 return setmetatable({ |
63 hostname = hostname; | 69 hostname = idna_to_ascii(hostname); |
64 port = port; | 70 port = port; |
65 conn_type = conn_type or "tcp"; | 71 conn_type = conn_type or "tcp"; |
66 extra = extra; | 72 extra = extra; |
67 }, resolver_mt); | 73 }, resolver_mt); |
68 end | 74 end |