Software / code / prosody
Comparison
core/s2smanager.lua @ 4106:e19fc274e182
s2smanager: Don't bounce error replies for error and result stanzas.
| author | Waqas Hussain <waqas20@gmail.com> |
|---|---|
| date | Mon, 10 Jan 2011 21:11:06 +0500 |
| parent | 4028:f596e1a5e88a |
| child | 4107:c9363102afd2 |
| child | 4127:f80b7a92da67 |
comparison
equal
deleted
inserted
replaced
| 4105:08560575762f | 4106:e19fc274e182 |
|---|---|
| 68 end; | 68 end; |
| 69 dummy = true; | 69 dummy = true; |
| 70 }; | 70 }; |
| 71 for i, data in ipairs(sendq) do | 71 for i, data in ipairs(sendq) do |
| 72 local reply = data[2]; | 72 local reply = data[2]; |
| 73 local xmlns = reply.attr.xmlns; | 73 if reply and not(reply.attr.xmlns) and bouncy_stanzas[reply.name] then |
| 74 if not(xmlns) and bouncy_stanzas[reply.name] then | |
| 75 reply.attr.type = "error"; | 74 reply.attr.type = "error"; |
| 76 reply:tag("error", {type = "cancel"}) | 75 reply:tag("error", {type = "cancel"}) |
| 77 :tag("remote-server-not-found", {xmlns = "urn:ietf:params:xml:ns:xmpp-stanzas"}):up(); | 76 :tag("remote-server-not-found", {xmlns = "urn:ietf:params:xml:ns:xmpp-stanzas"}):up(); |
| 78 if reason then | 77 if reason then |
| 79 reply:tag("text", {xmlns = "urn:ietf:params:xml:ns:xmpp-stanzas"}):text("Connection failed: "..reason):up(); | 78 reply:tag("text", {xmlns = "urn:ietf:params:xml:ns:xmpp-stanzas"}):text("Connection failed: "..reason):up(); |
| 96 -- We have a connection to this host already | 95 -- We have a connection to this host already |
| 97 if host.type == "s2sout_unauthed" and (data.name ~= "db:verify" or not host.dialback_key) then | 96 if host.type == "s2sout_unauthed" and (data.name ~= "db:verify" or not host.dialback_key) then |
| 98 (host.log or log)("debug", "trying to send over unauthed s2sout to "..to_host); | 97 (host.log or log)("debug", "trying to send over unauthed s2sout to "..to_host); |
| 99 | 98 |
| 100 -- Queue stanza until we are able to send it | 99 -- Queue stanza until we are able to send it |
| 101 if host.sendq then t_insert(host.sendq, {tostring(data), st.reply(data)}); | 100 if host.sendq then t_insert(host.sendq, {tostring(data), data.attr.type ~= "error" and data.attr.type ~= "result" and st.reply(data)}); |
| 102 else host.sendq = { {tostring(data), st.reply(data)} }; end | 101 else host.sendq = { {tostring(data), data.attr.type ~= "error" and data.attr.type ~= "result" and st.reply(data)} }; end |
| 103 host.log("debug", "stanza [%s] queued ", data.name); | 102 host.log("debug", "stanza [%s] queued ", data.name); |
| 104 elseif host.type == "local" or host.type == "component" then | 103 elseif host.type == "local" or host.type == "component" then |
| 105 log("error", "Trying to send a stanza to ourselves??") | 104 log("error", "Trying to send a stanza to ourselves??") |
| 106 log("error", "Traceback: %s", get_traceback()); | 105 log("error", "Traceback: %s", get_traceback()); |
| 107 log("error", "Stanza: %s", tostring(data)); | 106 log("error", "Stanza: %s", tostring(data)); |
| 119 else | 118 else |
| 120 log("debug", "opening a new outgoing connection for this stanza"); | 119 log("debug", "opening a new outgoing connection for this stanza"); |
| 121 local host_session = new_outgoing(from_host, to_host); | 120 local host_session = new_outgoing(from_host, to_host); |
| 122 | 121 |
| 123 -- Store in buffer | 122 -- Store in buffer |
| 124 host_session.sendq = { {tostring(data), st.reply(data)} }; | 123 host_session.sendq = { {tostring(data), data.attr.type ~= "error" and data.attr.type ~= "result" and st.reply(data)} }; |
| 125 log("debug", "stanza [%s] queued until connection complete", tostring(data.name)); | 124 log("debug", "stanza [%s] queued until connection complete", tostring(data.name)); |
| 126 if (not host_session.connecting) and (not host_session.conn) then | 125 if (not host_session.connecting) and (not host_session.conn) then |
| 127 log("warn", "Connection to %s failed already, destroying session...", to_host); | 126 log("warn", "Connection to %s failed already, destroying session...", to_host); |
| 128 if not destroy_session(host_session, "Connection failed") then | 127 if not destroy_session(host_session, "Connection failed") then |
| 129 -- Already destroyed, we need to bounce our stanza | 128 -- Already destroyed, we need to bounce our stanza |