Mercurial > prosody-hg
comparison core/s2smanager.lua @ 3431:c499f4752cd8
s2smanager: Only bounce real stanzas on s2s failure, not dialback and friends (thanks elghinn)
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Tue, 03 Aug 2010 09:39:05 +0100 |
| parents | c7acddf80583 |
| children | 7f3e45955725 |
comparison
equal
deleted
inserted
replaced
| 3430:970690b3cb28 | 3431:c499f4752cd8 |
|---|---|
| 55 | 55 |
| 56 function compare_srv_priorities(a,b) | 56 function compare_srv_priorities(a,b) |
| 57 return a.priority < b.priority or (a.priority == b.priority and a.weight > b.weight); | 57 return a.priority < b.priority or (a.priority == b.priority and a.weight > b.weight); |
| 58 end | 58 end |
| 59 | 59 |
| 60 local bouncy_stanzas = { message = true, presence = true, iq = true }; | |
| 60 local function bounce_sendq(session, reason) | 61 local function bounce_sendq(session, reason) |
| 61 local sendq = session.sendq; | 62 local sendq = session.sendq; |
| 62 if sendq then | 63 if sendq then |
| 63 session.log("info", "sending error replies for "..#sendq.." queued stanzas because of failed outgoing connection to "..tostring(session.to_host)); | 64 session.log("info", "sending error replies for "..#sendq.." queued stanzas because of failed outgoing connection to "..tostring(session.to_host)); |
| 64 local dummy = { | 65 local dummy = { |
| 69 dummy = true; | 70 dummy = true; |
| 70 }; | 71 }; |
| 71 for i, data in ipairs(sendq) do | 72 for i, data in ipairs(sendq) do |
| 72 local reply = data[2]; | 73 local reply = data[2]; |
| 73 local xmlns = reply.attr.xmlns; | 74 local xmlns = reply.attr.xmlns; |
| 74 if not xmlns then | 75 if not xmlns and bouncy_stanzas[reply.name] then |
| 75 reply.attr.type = "error"; | 76 reply.attr.type = "error"; |
| 76 reply:tag("error", {type = "cancel"}) | 77 reply:tag("error", {type = "cancel"}) |
| 77 :tag("remote-server-not-found", {xmlns = "urn:ietf:params:xml:ns:xmpp-stanzas"}):up(); | 78 :tag("remote-server-not-found", {xmlns = "urn:ietf:params:xml:ns:xmpp-stanzas"}):up(); |
| 78 if reason then | 79 if reason then |
| 79 reply:tag("text", {xmlns = "urn:ietf:params:xml:ns:xmpp-stanzas"}):text("Connection failed: "..reason):up(); | 80 reply:tag("text", {xmlns = "urn:ietf:params:xml:ns:xmpp-stanzas"}):text("Connection failed: "..reason):up(); |
