Software /
code /
prosody
Comparison
net/resolvers/basic.lua @ 10439:97c0f5fe5f41 0.11
net.resolvers.basic: Normalise IP literals, ensures net.server is happy
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 24 Nov 2019 04:41:07 +0100 |
parent | 10437:fcfc8f4d14a8 |
child | 10441:f2c9abc71f08 |
child | 11007:1d8e1f7a587c |
comparison
equal
deleted
inserted
replaced
10437:fcfc8f4d14a8 | 10439:97c0f5fe5f41 |
---|---|
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 | 5 |
5 local methods = {}; | 6 local methods = {}; |
6 local resolver_mt = { __index = methods }; | 7 local resolver_mt = { __index = methods }; |
7 | 8 |
61 local is_ip = inet_pton(hostname); | 62 local is_ip = inet_pton(hostname); |
62 if not is_ip and hostname:sub(1,1) == '[' then | 63 if not is_ip and hostname:sub(1,1) == '[' then |
63 is_ip = inet_pton(hostname:sub(2,-2)); | 64 is_ip = inet_pton(hostname:sub(2,-2)); |
64 end | 65 end |
65 if is_ip then | 66 if is_ip then |
67 hostname = inet_ntop(is_ip); | |
66 if #is_ip == 16 then | 68 if #is_ip == 16 then |
67 targets = { { conn_type.."6", hostname, port, extra } }; | 69 targets = { { conn_type.."6", hostname, port, extra } }; |
68 elseif #is_ip == 4 then | 70 elseif #is_ip == 4 then |
69 targets = { { conn_type.."4", hostname, port, extra } }; | 71 targets = { { conn_type.."4", hostname, port, extra } }; |
70 end | 72 end |