net/resolvers/basic.lua
branch0.11
changeset 10443 97c0f5fe5f41
parent 10441 fcfc8f4d14a8
child 10445 f2c9abc71f08
child 11011 1d8e1f7a587c
equal deleted inserted replaced
10441:fcfc8f4d14a8 10443: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