From ca50a5f5181ff319b7feecacc2fc540736938245 Mon Sep 17 00:00:00 2001 From: Cloud Wu Date: Thu, 28 May 2015 16:10:19 +0800 Subject: [PATCH] dns support underscore --- lualib/dns.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lualib/dns.lua b/lualib/dns.lua index a38c00e6..6244b314 100644 --- a/lualib/dns.lua +++ b/lualib/dns.lua @@ -91,7 +91,7 @@ local function verify_domain_name(name) if not name:match("^[%l%d-%.]+$") then return false end - for w in name:gmatch("([%w-]+)%.?") do + for w in name:gmatch("([_%w%-]+)%.?") do if #w > MAX_LABEL_LEN then return false end @@ -113,7 +113,7 @@ end local function pack_question(name, qtype, qclass) local labels = {} - for w in name:gmatch("([%w-]+)%.?") do + for w in name:gmatch("([_%w%-]+)%.?") do table.insert(labels, string.pack("s1",w)) end table.insert(labels, '\0') @@ -282,7 +282,7 @@ function dns.resolve(name, ipv6) qdcount = 1, } local req = pack_header(question_header) .. pack_question(name, qtype, QCLASS.IN) - assert(dns_server, "Call dns.server fist") + assert(dns_server, "Call dns.server first") socket.write(dns_server, req) return suspend(question_header.tid, name, qtype) end