Software /
code /
prosody
Comparison
net/dns.lua @ 8154:6300394bb713
Merge 0.9->0.10
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 27 May 2017 16:42:50 +0200 |
parent | 7527:936b78e9f399 |
parent | 8151:2c65f8be38aa |
child | 8164:a395957f3bf2 |
comparison
equal
deleted
inserted
replaced
8149:1dc6efcc420a | 8154:6300394bb713 |
---|---|
135 | 135 |
136 local function prune(rrs, time, soft) -- - - - - - - - - - - - - - - prune | 136 local function prune(rrs, time, soft) -- - - - - - - - - - - - - - - prune |
137 time = time or socket.gettime(); | 137 time = time or socket.gettime(); |
138 for i,rr in ipairs(rrs) do | 138 for i,rr in ipairs(rrs) do |
139 if rr.tod then | 139 if rr.tod then |
140 -- rr.tod = rr.tod - 50 -- accelerated decripitude | 140 if rr.tod < time then |
141 rr.ttl = math.floor(rr.tod - time); | |
142 if rr.ttl <= 0 then | |
143 rrs[rr[rr.type:lower()]] = nil; | 141 rrs[rr[rr.type:lower()]] = nil; |
144 table.remove(rrs, i); | 142 table.remove(rrs, i); |
145 return prune(rrs, time, soft); -- Re-iterate | 143 return prune(rrs, time, soft); -- Re-iterate |
146 end | 144 end |
147 elseif soft == 'soft' then -- What is this? I forget! | 145 elseif soft == 'soft' then -- What is this? I forget! |
504 rr.type = dns.type[self:word()] or rr.type; | 502 rr.type = dns.type[self:word()] or rr.type; |
505 rr.class = dns.class[self:word()] or rr.class; | 503 rr.class = dns.class[self:word()] or rr.class; |
506 rr.ttl = 0x10000*self:word() + self:word(); | 504 rr.ttl = 0x10000*self:word() + self:word(); |
507 rr.rdlength = self:word(); | 505 rr.rdlength = self:word(); |
508 | 506 |
509 if rr.ttl <= 0 then | 507 rr.tod = self.time + rr.ttl; |
510 rr.tod = self.time + 30; | |
511 else | |
512 rr.tod = self.time + rr.ttl; | |
513 end | |
514 | 508 |
515 local remember = self.offset; | 509 local remember = self.offset; |
516 local rr_parser = self[dns.type[rr.type]]; | 510 local rr_parser = self[dns.type[rr.type]]; |
517 if rr_parser then rr_parser(self, rr); end | 511 if rr_parser then rr_parser(self, rr); end |
518 self.offset = remember; | 512 self.offset = remember; |