Comparison

net/dns.lua @ 378:47fdbd074641

Fix dns for poor Windows users, who have never seen a resolv.conf
author Matthew Wild <mwild1@gmail.com>
date Sun, 23 Nov 2008 02:50:57 +0000
parent 337:4a1dd1c2c219
child 379:c5617678cd7b
comparison
equal deleted inserted replaced
377:12f483fe534b 378:47fdbd074641
499 self:addnameserver (address) 499 self:addnameserver (address)
500 end 500 end
501 501
502 502
503 function resolver:adddefaultnameservers () -- - - - - adddefaultnameservers 503 function resolver:adddefaultnameservers () -- - - - - adddefaultnameservers
504 for line in io.lines ('/etc/resolv.conf') do 504 local resolv_conf = io.open("/etc/resolv.conf");
505 if not resolv_conf then return nil; end
506 for line in resolv_conf:lines() do
505 address = string.match (line, 'nameserver%s+(%d+%.%d+%.%d+%.%d+)') 507 address = string.match (line, 'nameserver%s+(%d+%.%d+%.%d+%.%d+)')
506 if address then self:addnameserver (address) end 508 if address then self:addnameserver (address) end
507 end end 509 end end
508 510
509 511