Changeset

8902:ac21f13798ae

Merge 0.10->trunk
author Kim Alvefur <zash@zash.se>
date Sat, 09 Jun 2018 15:47:59 +0200
parents 8896:739deb514140 (current diff) 8901:eae606b9266c (diff)
children 8903:c5d5dfaa8d38
files net/dns.lua plugins/mod_s2s/s2sout.lib.lua
diffstat 2 files changed, 12 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/net/dns.lua	Sun Jun 03 00:57:51 2018 +0200
+++ b/net/dns.lua	Sat Jun 09 15:47:59 2018 +0200
@@ -88,9 +88,10 @@
 end
 
 
-local function augment (t)    -- - - - - - - - - - - - - - - - - - - -  augment
+local function augment (t, prefix)  -- - - - - - - - - - - - - - - - -  augment
 	local a = {};
-	for i,s in pairs(t) do
+	for i = 1, 0xffff do
+		local s = t[i] or ("%s%d"):format(prefix, i);
 		a[i] = s;
 		a[s] = s;
 		a[string.lower(s)] = s;
@@ -121,8 +122,8 @@
 dns.classes = { 'IN', 'CS', 'CH', 'HS', [255] = '*' };
 
 
-dns.type      = augment (dns.types);
-dns.class     = augment (dns.classes);
+dns.type      = augment (dns.types, "TYPE");
+dns.class     = augment (dns.classes, "CLASS");
 dns.typecode  = encode  (dns.types);
 dns.classcode = encode  (dns.classes);
 
@@ -686,7 +687,7 @@
 	self.cache = self.cache or setmetatable({}, cache_metatable);
 	local rrs = get(self.cache, qclass, type, qname) or
 		set(self.cache, qclass, type, qname, setmetatable({}, rrs_metatable));
-	if not rrs[rr[qtype:lower()]] then
+	if rr[qtype:lower()] and not rrs[rr[qtype:lower()]] then
 		rrs[rr[qtype:lower()]] = true;
 		append(rrs, rr);
 	end
@@ -903,7 +904,11 @@
 		--self.print(response);
 
 		for _, rr in pairs(response.answer) do
-			self:remember(rr, response.question[1].type);
+			self:remember(rr, rr.type);
+		end
+
+		for _, rr in pairs(response.additional) do
+			self:remember(rr, rr.type);
 		end
 
 		-- retire the query
--- a/plugins/mod_s2s/s2sout.lib.lua	Sun Jun 03 00:57:51 2018 +0200
+++ b/plugins/mod_s2s/s2sout.lib.lua	Sat Jun 09 15:47:59 2018 +0200
@@ -30,7 +30,6 @@
 local has_ipv4, has_ipv6;
 
 local dns_timeout = module:get_option_number("dns_timeout", 15);
-dns.settimeout(dns_timeout);
 local resolvers = module:get_option_set("s2s_dns_resolvers")
 
 local s2sout = {};
@@ -51,6 +50,7 @@
 	host_session.version = 1;
 
 	host_session.resolver = adns.resolver();
+	host_session.resolver._resolver:settimeout(dns_timeout);
 	if resolvers then
 		for resolver in resolvers do
 			host_session.resolver._resolver:addnameserver(resolver);