mod_dialback: More robust handling of multiple outstanding dialback requests for the same domain, fixes intermittent s2s with some (patched?) ejabberds
authorMatthew Wild <mwild1@gmail.com>
Mon, 06 Jun 2011 22:51:33 +0100
changeset 4314 1e1110840965
parent 4313 42d7d09fdda0
child 4315 51706d2b9f77
mod_dialback: More robust handling of multiple outstanding dialback requests for the same domain, fixes intermittent s2s with some (patched?) ejabberds
plugins/mod_dialback.lua
--- a/plugins/mod_dialback.lua	Sun Jun 05 12:28:49 2011 +0100
+++ b/plugins/mod_dialback.lua	Mon Jun 06 22:51:33 2011 +0100
@@ -60,7 +60,7 @@
 			return true;
 		end
 		
-		dialback_requests[attr.from] = origin;
+		dialback_requests[attr.from.."/"..origin.streamid] = origin;
 		
 		if not origin.from_host then
 			-- Just used for friendlier logging
@@ -83,8 +83,8 @@
 	
 	if origin.type == "s2sout_unauthed" or origin.type == "s2sout" then
 		local attr = stanza.attr;
-		local dialback_verifying = dialback_requests[attr.from];
-		if dialback_verifying then
+		local dialback_verifying = dialback_requests[attr.from.."/"..(attr.id or "")];
+		if dialback_verifying and attr.from == origin.to_host then
 			local valid;
 			if attr.type == "valid" then
 				s2s_make_authenticated(dialback_verifying, attr.from);
@@ -101,7 +101,7 @@
 						st.stanza("db:result", { from = attr.to, to = attr.from, id = attr.id, type = valid })
 								:text(dialback_verifying.hosts[attr.from].dialback_key));
 			end
-			dialback_requests[attr.from] = nil;
+			dialback_requests[attr.from.."/"..(attr.id or "")] = nil;
 		end
 		return true;
 	end