Comparison

core/s2smanager.lua @ 2781:4b5881b6bbfc

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 2780:f8232abcab2a
child 2783:57611584e27d
comparison
equal deleted inserted replaced
2780:f8232abcab2a 2781:4b5881b6bbfc
52 52
53 function compare_srv_priorities(a,b) 53 function compare_srv_priorities(a,b)
54 return a.priority < b.priority or (a.priority == b.priority and a.weight > b.weight); 54 return a.priority < b.priority or (a.priority == b.priority and a.weight > b.weight);
55 end 55 end
56 56
57 local function bounce_sendq(session) 57 local function bounce_sendq(session, reason)
58 local sendq = session.sendq; 58 local sendq = session.sendq;
59 if sendq then 59 if sendq then
60 session.log("info", "sending error replies for "..#sendq.." queued stanzas because of failed outgoing connection to "..tostring(session.to_host)); 60 session.log("info", "sending error replies for "..#sendq.." queued stanzas because of failed outgoing connection to "..tostring(session.to_host));
61 local dummy = { 61 local dummy = {
62 type = "s2sin"; 62 type = "s2sin";
70 local xmlns = reply.attr.xmlns; 70 local xmlns = reply.attr.xmlns;
71 if not xmlns or xmlns == "jabber:client" or xmlns == "jabber:server" then 71 if not xmlns or xmlns == "jabber:client" or xmlns == "jabber:server" then
72 reply.attr.type = "error"; 72 reply.attr.type = "error";
73 reply:tag("error", {type = "cancel"}) 73 reply:tag("error", {type = "cancel"})
74 :tag("remote-server-not-found", {xmlns = "urn:ietf:params:xml:ns:xmpp-stanzas"}):up(); 74 :tag("remote-server-not-found", {xmlns = "urn:ietf:params:xml:ns:xmpp-stanzas"}):up();
75 if reason then
76 reply:tag("text", {xmlns = "urn:ietf:params:xml:ns:xmpp-stanzas"}):text("Connection failed: "..reason):up();
77 end
75 core_process_stanza(dummy, reply); 78 core_process_stanza(dummy, reply);
76 end 79 end
77 sendq[i] = nil; 80 sendq[i] = nil;
78 end 81 end
79 session.sendq = nil; 82 session.sendq = nil;
489 492
490 session.srv_hosts = nil; 493 session.srv_hosts = nil;
491 end 494 end
492 end 495 end
493 496
494 function destroy_session(session) 497 function destroy_session(session, reason)
495 (session.log or log)("info", "Destroying "..tostring(session.direction).." session "..tostring(session.from_host).."->"..tostring(session.to_host)); 498 (session.log or log)("info", "Destroying "..tostring(session.direction).." session "..tostring(session.from_host).."->"..tostring(session.to_host));
496 499
497 if session.direction == "outgoing" then 500 if session.direction == "outgoing" then
498 hosts[session.from_host].s2sout[session.to_host] = nil; 501 hosts[session.from_host].s2sout[session.to_host] = nil;
499 bounce_sendq(session); 502 bounce_sendq(session, reason);
500 elseif session.direction == "incoming" then 503 elseif session.direction == "incoming" then
501 incoming_s2s[session] = nil; 504 incoming_s2s[session] = nil;
502 end 505 end
503 506
504 for k in pairs(session) do 507 for k in pairs(session) do