536 end |
536 end |
537 else -- posix |
537 else -- posix |
538 local resolv_conf = io.open("/etc/resolv.conf"); |
538 local resolv_conf = io.open("/etc/resolv.conf"); |
539 if resolv_conf then |
539 if resolv_conf then |
540 for line in resolv_conf:lines() do |
540 for line in resolv_conf:lines() do |
541 local address = line:gsub("#.*$", ""):match('^%s*nameserver%s+(%d+%.%d+%.%d+%.%d+)%s*$'); |
541 line = line:gsub("#.*$", "") |
542 if address then self:addnameserver(address) end |
542 :match('^%s*nameserver%s+(.*)%s*$'); |
|
543 if line then |
|
544 line:gsub("%f[%d.](%d+%.%d+%.%d+%.%d+)%f[^%d.]", function (address) |
|
545 self:addnameserver(address) |
|
546 end); |
|
547 end |
543 end |
548 end |
544 end |
549 end |
545 if not self.server or #self.server == 0 then |
550 if not self.server or #self.server == 0 then |
546 -- TODO log warning about no nameservers, adding localhost as the default nameserver |
551 -- TODO log warning about no nameservers, adding localhost as the default nameserver |
547 self:addnameserver("127.0.0.1"); |
552 self:addnameserver("127.0.0.1"); |