Software /
code /
prosody
Comparison
core/s2smanager.lua @ 2368:4726cd9a6318
s2smanager: Have both destroy_session and bounce_sendq accept a reason string to include in bounced stanzas
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 17 Dec 2009 18:59:29 +0000 |
parent | 2231:288832cdec52 |
child | 2376:c5faafa89f50 |
comparison
equal
deleted
inserted
replaced
2367:22dc9005360f | 2368:4726cd9a6318 |
---|---|
49 | 49 |
50 module "s2smanager" | 50 module "s2smanager" |
51 | 51 |
52 local function compare_srv_priorities(a,b) return a.priority < b.priority or a.weight < b.weight; end | 52 local function compare_srv_priorities(a,b) return a.priority < b.priority or a.weight < b.weight; end |
53 | 53 |
54 local function bounce_sendq(session) | 54 local function bounce_sendq(session, reason) |
55 local sendq = session.sendq; | 55 local sendq = session.sendq; |
56 if sendq then | 56 if sendq then |
57 session.log("info", "sending error replies for "..#sendq.." queued stanzas because of failed outgoing connection to "..tostring(session.to_host)); | 57 session.log("info", "sending error replies for "..#sendq.." queued stanzas because of failed outgoing connection to "..tostring(session.to_host)); |
58 local dummy = { | 58 local dummy = { |
59 type = "s2sin"; | 59 type = "s2sin"; |
67 local xmlns = reply.attr.xmlns; | 67 local xmlns = reply.attr.xmlns; |
68 if not xmlns or xmlns == "jabber:client" or xmlns == "jabber:server" then | 68 if not xmlns or xmlns == "jabber:client" or xmlns == "jabber:server" then |
69 reply.attr.type = "error"; | 69 reply.attr.type = "error"; |
70 reply:tag("error", {type = "cancel"}) | 70 reply:tag("error", {type = "cancel"}) |
71 :tag("remote-server-not-found", {xmlns = "urn:ietf:params:xml:ns:xmpp-stanzas"}):up(); | 71 :tag("remote-server-not-found", {xmlns = "urn:ietf:params:xml:ns:xmpp-stanzas"}):up(); |
72 if reason then | |
73 reply:tag("text", {xmlns = "urn:ietf:params:xml:ns:xmpp-stanzas"}):text("Connection failed: "..reason):up(); | |
74 end | |
72 core_process_stanza(dummy, reply); | 75 core_process_stanza(dummy, reply); |
73 end | 76 end |
74 sendq[i] = nil; | 77 sendq[i] = nil; |
75 end | 78 end |
76 session.sendq = nil; | 79 session.sendq = nil; |
481 | 484 |
482 session.srv_hosts = nil; | 485 session.srv_hosts = nil; |
483 end | 486 end |
484 end | 487 end |
485 | 488 |
486 function destroy_session(session) | 489 function destroy_session(session, reason) |
487 (session.log or log)("info", "Destroying "..tostring(session.direction).." session "..tostring(session.from_host).."->"..tostring(session.to_host)); | 490 (session.log or log)("info", "Destroying "..tostring(session.direction).." session "..tostring(session.from_host).."->"..tostring(session.to_host)); |
488 | 491 |
489 if session.direction == "outgoing" then | 492 if session.direction == "outgoing" then |
490 hosts[session.from_host].s2sout[session.to_host] = nil; | 493 hosts[session.from_host].s2sout[session.to_host] = nil; |
491 bounce_sendq(session); | 494 bounce_sendq(session, reason); |
492 elseif session.direction == "incoming" then | 495 elseif session.direction == "incoming" then |
493 incoming_s2s[session] = nil; | 496 incoming_s2s[session] = nil; |
494 end | 497 end |
495 | 498 |
496 for k in pairs(session) do | 499 for k in pairs(session) do |