Changeset

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 10348:3852fc91b2fc
children 10385:62a7042e0771
files net/resolvers/basic.lua net/resolvers/service.lua
diffstat 2 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/net/resolvers/basic.lua	Sun Oct 20 20:52:14 2019 +0200
+++ b/net/resolvers/basic.lua	Sat Nov 02 19:24:26 2019 +0100
@@ -1,5 +1,6 @@
 local adns = require "net.adns";
 local inet_pton = require "util.net".pton;
+local idna_to_ascii = require "util.encodings".idna.to_ascii;
 
 local methods = {};
 local resolver_mt = { __index = methods };
@@ -59,7 +60,7 @@
 
 local function new(hostname, port, conn_type, extra)
 	return setmetatable({
-		hostname = hostname;
+		hostname = idna_to_ascii(hostname);
 		port = port;
 		conn_type = conn_type or "tcp";
 		extra = extra;
--- a/net/resolvers/service.lua	Sun Oct 20 20:52:14 2019 +0200
+++ b/net/resolvers/service.lua	Sat Nov 02 19:24:26 2019 +0100
@@ -1,5 +1,6 @@
 local adns = require "net.adns";
 local basic = require "net.resolvers.basic";
+local idna_to_ascii = require "util.encodings".idna.to_ascii;
 
 local methods = {};
 local resolver_mt = { __index = methods };
@@ -58,7 +59,7 @@
 
 local function new(hostname, service, conn_type, extra)
 	return setmetatable({
-		hostname = hostname;
+		hostname = idna_to_ascii(hostname);
 		service = service;
 		conn_type = conn_type or "tcp";
 		extra = extra;