From 775c721023130e7ced2abb28ec7ff3a035328253 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Thu, 24 Sep 2009 23:25:18 +0100 Subject: net.dns: Stricter matching of nameserver entries in resolv.conf --- net/dns.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'net') diff --git a/net/dns.lua b/net/dns.lua index da06ceaa..8448b7ca 100644 --- a/net/dns.lua +++ b/net/dns.lua @@ -507,7 +507,7 @@ function resolver:adddefaultnameservers () -- - - - - adddefaultnameservers local resolv_conf = io.open("/etc/resolv.conf"); if resolv_conf then for line in resolv_conf:lines() do - local address = string.match (line, '^%s*nameserver%s+(%d+%.%d+%.%d+%.%d+)') + local address = string.match (line, '^%s*nameserver%s+(%d+%.%d+%.%d+%.%d+)%s*$') if address then self:addnameserver (address) end end elseif os.getenv("WINDIR") then -- cgit v1.2.3 From 9118f712274368d5794fb8b8a2831f678ae1c15b Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Thu, 24 Sep 2009 23:46:12 +0100 Subject: net.dns: Remove elements from the cache when expired so as to not leave holes in the array --- net/dns.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'net') diff --git a/net/dns.lua b/net/dns.lua index 8448b7ca..d6462031 100644 --- a/net/dns.lua +++ b/net/dns.lua @@ -95,7 +95,10 @@ local function prune (rrs, time, soft) -- - - - - - - - - - - - - - - prune if rr.tod then -- rr.tod = rr.tod - 50 -- accelerated decripitude rr.ttl = math.floor (rr.tod - time) - if rr.ttl <= 0 then rrs[i] = nil end + if rr.ttl <= 0 then + table.remove(rrs, i); + return prune(rrs, time, soft); -- Re-iterate + end elseif soft == 'soft' then -- What is this? I forget! assert (rr.ttl == 0) -- cgit v1.2.3