Mercurial > prosody-hg
comparison net/resolvers/basic.lua @ 10441:f2c9abc71f08
Merge 0.11->trunk
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sun, 24 Nov 2019 04:46:36 +0100 |
| parents | 55490be0dc29 97c0f5fe5f41 |
| children | b13a31cea7d9 |
comparison
equal
deleted
inserted
replaced
| 10440:1ee87b4979c2 | 10441:f2c9abc71f08 |
|---|---|
| 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 inet_ntop = require "util.net".ntop; | |
| 3 local idna_to_ascii = require "util.encodings".idna.to_ascii; | 4 local idna_to_ascii = require "util.encodings".idna.to_ascii; |
| 4 local unpack = table.unpack or unpack; -- luacheck: ignore 113 | 5 local unpack = table.unpack or unpack; -- luacheck: ignore 113 |
| 5 | 6 |
| 6 local methods = {}; | 7 local methods = {}; |
| 7 local resolver_mt = { __index = methods }; | 8 local resolver_mt = { __index = methods }; |
| 62 local is_ip = inet_pton(hostname); | 63 local is_ip = inet_pton(hostname); |
| 63 if not is_ip and hostname:sub(1,1) == '[' then | 64 if not is_ip and hostname:sub(1,1) == '[' then |
| 64 is_ip = inet_pton(hostname:sub(2,-2)); | 65 is_ip = inet_pton(hostname:sub(2,-2)); |
| 65 end | 66 end |
| 66 if is_ip then | 67 if is_ip then |
| 68 hostname = inet_ntop(is_ip); | |
| 67 if #is_ip == 16 then | 69 if #is_ip == 16 then |
| 68 targets = { { conn_type.."6", hostname, port, extra } }; | 70 targets = { { conn_type.."6", hostname, port, extra } }; |
| 69 elseif #is_ip == 4 then | 71 elseif #is_ip == 4 then |
| 70 targets = { { conn_type.."4", hostname, port, extra } }; | 72 targets = { { conn_type.."4", hostname, port, extra } }; |
| 71 end | 73 end |
