# HG changeset patch
# User Kim Alvefur <zash@zash.se>
# Date 1567873949 -7200
# Node ID 5de65f30fe5e09b870a2a3000a407e5b53ac5840
# Parent  19d7a2e7b9c4c2089d94c729730cae6e1d6c2c1d
mod_s2s: Add function to send replies on s2sout connections that support incoming traffic

diff -r 19d7a2e7b9c4 -r 5de65f30fe5e plugins/mod_s2s/mod_s2s.lua
--- a/plugins/mod_s2s/mod_s2s.lua	Sat Sep 07 17:44:57 2019 +0200
+++ b/plugins/mod_s2s/mod_s2s.lua	Sat Sep 07 18:32:29 2019 +0200
@@ -208,6 +208,13 @@
 	if session.type == "s2sout" then
 		fire_global_event("s2sout-established", event_data);
 		hosts[from].events.fire_event("s2sout-established", event_data);
+
+		if session.incoming then
+			session.send = function(stanza)
+				return hosts[from].events.fire_event("route/remote", { from_host = from, to_host = to, stanza = stanza });
+			end;
+		end
+
 	else
 		local host_session = hosts[to];
 		session.send = function(stanza)