Comparison

net/resolvers/basic.lua @ 10437:fcfc8f4d14a8 0.11

net.resolvers.basic: Fix resolution of IPv6 literals (in brackets) (fixes #1459)
author Kim Alvefur <zash@zash.se>
date Sun, 24 Nov 2019 04:26:44 +0100
parent 10436:0d702ec77f0c
child 10438:55490be0dc29
child 10439:97c0f5fe5f41
comparison
equal deleted inserted replaced
10436:0d702ec77f0c 10437:fcfc8f4d14a8
57 local function new(hostname, port, conn_type, extra) 57 local function new(hostname, port, conn_type, extra)
58 local ascii_host = idna_to_ascii(hostname); 58 local ascii_host = idna_to_ascii(hostname);
59 local targets = nil; 59 local targets = nil;
60 60
61 local is_ip = inet_pton(hostname); 61 local is_ip = inet_pton(hostname);
62 if not is_ip and hostname:sub(1,1) == '[' then
63 is_ip = inet_pton(hostname:sub(2,-2));
64 end
62 if is_ip then 65 if is_ip then
63 if #is_ip == 16 then 66 if #is_ip == 16 then
64 targets = { { conn_type.."6", hostname, port, extra } }; 67 targets = { { conn_type.."6", hostname, port, extra } };
65 elseif #is_ip == 4 then 68 elseif #is_ip == 4 then
66 targets = { { conn_type.."4", hostname, port, extra } }; 69 targets = { { conn_type.."4", hostname, port, extra } };