Diff

net/dns.lua @ 8151:2c65f8be38aa

net.dns: Simplify expiry calculation (fixes #919)
author Kim Alvefur <zash@zash.se>
date Mon, 22 May 2017 05:32:11 +0200
parent 7093:388281be2bc7
child 8154:6300394bb713
child 8163:a55eb6c3b45c
line wrap: on
line diff
--- a/net/dns.lua	Mon Apr 17 21:40:06 2017 +0200
+++ b/net/dns.lua	Mon May 22 05:32:11 2017 +0200
@@ -137,9 +137,7 @@
 	time = time or socket.gettime();
 	for i,rr in ipairs(rrs) do
 		if rr.tod then
-			-- rr.tod = rr.tod - 50    -- accelerated decripitude
-			rr.ttl = math.floor(rr.tod - time);
-			if rr.ttl <= 0 then
+			if rr.tod < time then
 				rrs[rr[rr.type:lower()]] = nil;
 				table.remove(rrs, i);
 				return prune(rrs, time, soft); -- Re-iterate
@@ -515,11 +513,7 @@
 	rr.ttl      = 0x10000*self:word() + self:word();
 	rr.rdlength = self:word();
 
-	if rr.ttl <= 0 then
-		rr.tod = self.time + 30;
-	else
-		rr.tod = self.time + rr.ttl;
-	end
+	rr.tod = self.time + rr.ttl;
 
 	local remember = self.offset;
 	local rr_parser = self[dns.type[rr.type]];