diff options
author | Matthew Wild <mwild1@gmail.com> | 2010-03-05 18:15:08 +0000 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2010-03-05 18:15:08 +0000 |
commit | 322f02b17fac1dc673a1250ddbc4a954dec98696 (patch) | |
tree | f79cab9d2458e5343119c3822cf15908d0fedc75 /net | |
parent | c071b4638d4a78d9c7e76ae973553e04cb5e22b6 (diff) | |
download | prosody-322f02b17fac1dc673a1250ddbc4a954dec98696.tar.gz prosody-322f02b17fac1dc673a1250ddbc4a954dec98696.zip |
net.dns: More reliable parsing of resolv.conf - allow multiple nameserver IPs on one line (thanks dersd)
Diffstat (limited to 'net')
-rw-r--r-- | net/dns.lua | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/net/dns.lua b/net/dns.lua index ca5f3c62..7d1cba8e 100644 --- a/net/dns.lua +++ b/net/dns.lua @@ -538,8 +538,13 @@ 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 = line:gsub("#.*$", ""):match('^%s*nameserver%s+(%d+%.%d+%.%d+%.%d+)%s*$'); - if address then self:addnameserver(address) end + line = line:gsub("#.*$", "") + :match('^%s*nameserver%s+(.*)%s*$'); + if line then + line:gsub("%f[%d.](%d+%.%d+%.%d+%.%d+)%f[^%d.]", function (address) + self:addnameserver(address) + end); + end end end if not self.server or #self.server == 0 then |