Software /
code /
prosody
Diff
net/dns.lua @ 379:c5617678cd7b
Fix various mistakes in dns.lua
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sun, 23 Nov 2008 03:00:20 +0000 |
parent | 378:47fdbd074641 |
child | 399:93b6587d9afb |
line wrap: on
line diff
--- a/net/dns.lua Sun Nov 23 02:50:57 2008 +0000 +++ b/net/dns.lua Sun Nov 23 03:00:20 2008 +0000 @@ -19,8 +19,8 @@ local coroutine, io, math, socket, string, table = coroutine, io, math, socket, string, table -local ipairs, next, pairs, print, setmetatable, tostring = - ipairs, next, pairs, print, setmetatable, tostring +local ipairs, next, pairs, print, setmetatable, tostring, assert, error = + ipairs, next, pairs, print, setmetatable, tostring, assert, error local get, set = ztact.get, ztact.set @@ -130,7 +130,7 @@ local rrs_metatable = {} -- - - - - - - - - - - - - - - - - - rrs_metatable function rrs_metatable.__tostring (rrs) - t = {} + local t = {} for i,rr in pairs (rrs) do append (t, tostring (rr)..'\n') end return table.concat (t) end @@ -504,7 +504,7 @@ local resolv_conf = io.open("/etc/resolv.conf"); if not resolv_conf then return nil; end for line in resolv_conf:lines() do - address = string.match (line, 'nameserver%s+(%d+%.%d+%.%d+%.%d+)') + local address = string.match (line, 'nameserver%s+(%d+%.%d+%.%d+%.%d+)') if address then self:addnameserver (address) end end end @@ -582,7 +582,7 @@ for class,types in pairs (self.cache or {}) do for type,names in pairs (types) do for name,rrs in pairs (names) do - prune (rrs, time, 'soft') + prune (rrs, self.time, 'soft') end end end else self.cache = {} end end @@ -594,7 +594,7 @@ if not self.server then self:adddefaultnameservers () end - local question = question or encodeQuestion (qname, qtype, qclass) + local question = encodeQuestion (qname, qtype, qclass) local peek = self:peek (qname, qtype, qclass) if peek then return peek end @@ -767,7 +767,7 @@ -- this function seems to be redundant with resolver.new () - r = { active = {}, cache = {}, unsorted = {}, wanted = {}, yielded = {} } + local r = { active = {}, cache = {}, unsorted = {}, wanted = {}, yielded = {} } setmetatable (r, resolver) setmetatable (r.cache, cache_metatable) setmetatable (r.unsorted, { __mode = 'kv' })