From 246bfb79cc233e8b1dabf007f87b2c6bce13c684 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Sun, 23 Nov 2008 02:50:57 +0000 Subject: Fix dns for poor Windows users, who have never seen a resolv.conf --- net/dns.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'net') diff --git a/net/dns.lua b/net/dns.lua index a75c1bf5..01ee133c 100644 --- a/net/dns.lua +++ b/net/dns.lua @@ -501,7 +501,9 @@ function resolver:setnameserver (address) -- - - - - - - - - - setnameserver function resolver:adddefaultnameservers () -- - - - - adddefaultnameservers - for line in io.lines ('/etc/resolv.conf') do + local resolv_conf = io.open("/etc/resolv.conf"); + if not resolv_conf then return nil; end + for line in resolv_conf:lines() do address = string.match (line, 'nameserver%s+(%d+%.%d+%.%d+%.%d+)') if address then self:addnameserver (address) end end end -- cgit v1.2.3