net.dns: Even better parsing of nameservers from resolv.conf

Fri, 25 Sep 2009 01:35:46 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Fri, 25 Sep 2009 01:35:46 +0100
changeset 1824
fc21e8832848
parent 1822
2f78ea5d0f11
child 1825
48cb27e2716e
child 1828
ced7a6b8bcd0

net.dns: Even better parsing of nameservers from resolv.conf

net/dns.lua file | annotate | diff | comparison | revisions
--- a/net/dns.lua	Thu Sep 24 23:46:12 2009 +0100
+++ b/net/dns.lua	Fri Sep 25 01:35:46 2009 +0100
@@ -510,7 +510,7 @@
   local resolv_conf = io.open("/etc/resolv.conf");
   if resolv_conf then
 	  for line in resolv_conf:lines() do
-		local address = string.match (line, '^%s*nameserver%s+(%d+%.%d+%.%d+%.%d+)%s*$')
+		local address = line:gsub("#.*$", ""):match('^%s*nameserver%s+(%d+%.%d+%.%d+%.%d+)%s*$')
 		if address then self:addnameserver (address)  end
 	  end
   elseif os.getenv("WINDIR") then

mercurial