Comparison

plugins/mod_s2s/mod_s2s.lua @ 8463:d81ebb1ef5ce

mod_s2s: Restructure some code
author Kim Alvefur <zash@zash.se>
date Tue, 05 Dec 2017 13:24:28 +0100
parent 8462:60d508f411a1
child 8483:6d47b74926dd
comparison
equal deleted inserted replaced
8462:60d508f411a1 8463:d81ebb1ef5ce
104 -- We have a connection to this host already 104 -- We have a connection to this host already
105 if host.type == "s2sout_unauthed" and (stanza.name ~= "db:verify" or not host.dialback_key) then 105 if host.type == "s2sout_unauthed" and (stanza.name ~= "db:verify" or not host.dialback_key) then
106 (host.log or log)("debug", "trying to send over unauthed s2sout to "..to_host); 106 (host.log or log)("debug", "trying to send over unauthed s2sout to "..to_host);
107 107
108 -- Queue stanza until we are able to send it 108 -- Queue stanza until we are able to send it
109 if host.sendq then t_insert(host.sendq, {tostring(stanza), stanza.attr.type ~= "error" and stanza.attr.type ~= "result" and st.reply(stanza)}); 109 local queued_item = {
110 else host.sendq = { {tostring(stanza), stanza.attr.type ~= "error" and stanza.attr.type ~= "result" and st.reply(stanza)} }; end 110 tostring(stanza),
111 stanza.attr.type ~= "error" and stanza.attr.type ~= "result" and st.reply(stanza);
112 };
113 if host.sendq then
114 t_insert(host.sendq, queued_item);
115 else
116 host.sendq = { queued_item };
117 end
111 host.log("debug", "stanza [%s] queued ", stanza.name); 118 host.log("debug", "stanza [%s] queued ", stanza.name);
112 return true; 119 return true;
113 elseif host.type == "local" or host.type == "component" then 120 elseif host.type == "local" or host.type == "component" then
114 log("error", "Trying to send a stanza to ourselves??") 121 log("error", "Trying to send a stanza to ourselves??")
115 log("error", "Traceback: %s", traceback()); 122 log("error", "Traceback: %s", traceback());