Software /
code /
prosody
Comparison
net/dns.lua @ 1827:fc21e8832848
net.dns: Even better parsing of nameservers from resolv.conf
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 25 Sep 2009 01:35:46 +0100 |
parent | 1822:2f78ea5d0f11 |
child | 1836:f4c88dd32724 |
child | 1949:e3d777d76b1a |
comparison
equal
deleted
inserted
replaced
1822:2f78ea5d0f11 | 1827:fc21e8832848 |
---|---|
508 | 508 |
509 function resolver:adddefaultnameservers () -- - - - - adddefaultnameservers | 509 function resolver:adddefaultnameservers () -- - - - - adddefaultnameservers |
510 local resolv_conf = io.open("/etc/resolv.conf"); | 510 local resolv_conf = io.open("/etc/resolv.conf"); |
511 if resolv_conf then | 511 if resolv_conf then |
512 for line in resolv_conf:lines() do | 512 for line in resolv_conf:lines() do |
513 local address = string.match (line, '^%s*nameserver%s+(%d+%.%d+%.%d+%.%d+)%s*$') | 513 local address = line:gsub("#.*$", ""):match('^%s*nameserver%s+(%d+%.%d+%.%d+%.%d+)%s*$') |
514 if address then self:addnameserver (address) end | 514 if address then self:addnameserver (address) end |
515 end | 515 end |
516 elseif os.getenv("WINDIR") then | 516 elseif os.getenv("WINDIR") then |
517 self:addnameserver ("208.67.222.222") | 517 self:addnameserver ("208.67.222.222") |
518 self:addnameserver ("208.67.220.220") | 518 self:addnameserver ("208.67.220.220") |