net.resolvers.basic: Fix resolution of IPv6 literals (in brackets) (fixes #1459) 0.11
authorKim Alvefur <zash@zash.se>
Sun, 24 Nov 2019 04:26:44 +0100
branch0.11
changeset 10441 fcfc8f4d14a8
parent 10440 0d702ec77f0c
child 10442 55490be0dc29
child 10443 97c0f5fe5f41
net.resolvers.basic: Fix resolution of IPv6 literals (in brackets) (fixes #1459)
net/resolvers/basic.lua
--- a/net/resolvers/basic.lua	Sun Nov 24 04:23:51 2019 +0100
+++ b/net/resolvers/basic.lua	Sun Nov 24 04:26:44 2019 +0100
@@ -59,6 +59,9 @@
 	local targets = nil;
 
 	local is_ip = inet_pton(hostname);
+	if not is_ip and hostname:sub(1,1) == '[' then
+		is_ip = inet_pton(hostname:sub(2,-2));
+	end
 	if is_ip then
 		if #is_ip == 16 then
 			targets = { { conn_type.."6", hostname, port, extra } };