Comparison

net/dns.lua @ 1820:3e0e9f80010a

net.dns: Stricter matching of nameserver entries in resolv.conf
author Matthew Wild <mwild1@gmail.com>
date Thu, 24 Sep 2009 23:25:18 +0100
parent 1815:e2f0c514d039
child 1822:2f78ea5d0f11
comparison
equal deleted inserted replaced
1815:e2f0c514d039 1820:3e0e9f80010a
505 505
506 function resolver:adddefaultnameservers () -- - - - - adddefaultnameservers 506 function resolver:adddefaultnameservers () -- - - - - adddefaultnameservers
507 local resolv_conf = io.open("/etc/resolv.conf"); 507 local resolv_conf = io.open("/etc/resolv.conf");
508 if resolv_conf then 508 if resolv_conf then
509 for line in resolv_conf:lines() do 509 for line in resolv_conf:lines() do
510 local address = string.match (line, '^%s*nameserver%s+(%d+%.%d+%.%d+%.%d+)') 510 local address = string.match (line, '^%s*nameserver%s+(%d+%.%d+%.%d+%.%d+)%s*$')
511 if address then self:addnameserver (address) end 511 if address then self:addnameserver (address) end
512 end 512 end
513 elseif os.getenv("WINDIR") then 513 elseif os.getenv("WINDIR") then
514 self:addnameserver ("208.67.222.222") 514 self:addnameserver ("208.67.222.222")
515 self:addnameserver ("208.67.220.220") 515 self:addnameserver ("208.67.220.220")