Mercurial > prosody-hg
comparison net/resolvers/service.lua @ 10384:94c9c574cd8a 0.11
net.resolvers: Apply IDNA conversion to ascii for DNS lookups (fixes #1426)
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sat, 02 Nov 2019 19:24:26 +0100 |
| parents | e09ddd061ec4 |
| children | 62a7042e0771 |
comparison
equal
deleted
inserted
replaced
| 10348:3852fc91b2fc | 10384:94c9c574cd8a |
|---|---|
| 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 | 4 |
| 4 local methods = {}; | 5 local methods = {}; |
| 5 local resolver_mt = { __index = methods }; | 6 local resolver_mt = { __index = methods }; |
| 6 | 7 |
| 7 -- Find the next target to connect to, and | 8 -- Find the next target to connect to, and |
| 56 end, "_" .. self.service .. "._" .. self.conn_type .. "." .. self.hostname, "SRV", "IN"); | 57 end, "_" .. self.service .. "._" .. self.conn_type .. "." .. self.hostname, "SRV", "IN"); |
| 57 end | 58 end |
| 58 | 59 |
| 59 local function new(hostname, service, conn_type, extra) | 60 local function new(hostname, service, conn_type, extra) |
| 60 return setmetatable({ | 61 return setmetatable({ |
| 61 hostname = hostname; | 62 hostname = idna_to_ascii(hostname); |
| 62 service = service; | 63 service = service; |
| 63 conn_type = conn_type or "tcp"; | 64 conn_type = conn_type or "tcp"; |
| 64 extra = extra; | 65 extra = extra; |
| 65 }, resolver_mt); | 66 }, resolver_mt); |
| 66 end | 67 end |
