Comparison

net/resolvers/service.lua @ 10386:cf93a951da37

Merge 0.11->trunk
author Kim Alvefur <zash@zash.se>
date Sat, 02 Nov 2019 19:38:12 +0100
parent 10121:33f287519bf6
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 basic = require "net.resolvers.basic"; 2 local basic = require "net.resolvers.basic";
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
21 else 22 else
22 cb(...); 23 cb(...);
23 end 24 end
24 end); 25 end);
25 return; 26 return;
27 end
28
29 if not self.hostname then
30 -- FIXME report IDNA error
31 cb(nil);
26 end 32 end
27 33
28 local targets = {}; 34 local targets = {};
29 local function ready() 35 local function ready()
30 self.targets = targets; 36 self.targets = targets;
61 end, "_" .. self.service .. "._" .. self.conn_type .. "." .. self.hostname, "SRV", "IN"); 67 end, "_" .. self.service .. "._" .. self.conn_type .. "." .. self.hostname, "SRV", "IN");
62 end 68 end
63 69
64 local function new(hostname, service, conn_type, extra) 70 local function new(hostname, service, conn_type, extra)
65 return setmetatable({ 71 return setmetatable({
66 hostname = hostname; 72 hostname = idna_to_ascii(hostname);
67 service = service; 73 service = service;
68 conn_type = conn_type or "tcp"; 74 conn_type = conn_type or "tcp";
69 extra = extra; 75 extra = extra;
70 }, resolver_mt); 76 }, resolver_mt);
71 end 77 end