Comparison

plugins/s2s/mod_s2s.lua @ 4755:844019f369a5

mod_s2s: Fix imports and remove some unused variables
author Matthew Wild <mwild1@gmail.com>
date Sat, 28 Apr 2012 03:06:14 +0100
parent 4752:27b724a698f8
child 4782:28e7664924bd
comparison
equal deleted inserted replaced
4754:449a78f91f0e 4755:844019f369a5
5 -- This project is MIT/X11 licensed. Please see the 5 -- This project is MIT/X11 licensed. Please see the
6 -- COPYING file in the source package for more information. 6 -- COPYING file in the source package for more information.
7 -- 7 --
8 8
9 module:set_global(); 9 module:set_global();
10
11 local prosody = prosody;
12 local hosts = prosody.hosts;
13 local core_process_stanza = prosody.core_process_stanza;
10 14
11 local tostring, type = tostring, type; 15 local tostring, type = tostring, type;
12 local t_insert = table.insert; 16 local t_insert = table.insert;
13 local xpcall, traceback = xpcall, debug.traceback; 17 local xpcall, traceback = xpcall, debug.traceback;
14 18
18 local nameprep = require "util.encodings".stringprep.nameprep; 22 local nameprep = require "util.encodings".stringprep.nameprep;
19 local new_xmpp_stream = require "util.xmppstream".new; 23 local new_xmpp_stream = require "util.xmppstream".new;
20 local s2s_new_incoming = require "core.s2smanager".new_incoming; 24 local s2s_new_incoming = require "core.s2smanager".new_incoming;
21 local s2s_new_outgoing = require "core.s2smanager".new_outgoing; 25 local s2s_new_outgoing = require "core.s2smanager".new_outgoing;
22 local s2s_destroy_session = require "core.s2smanager".destroy_session; 26 local s2s_destroy_session = require "core.s2smanager".destroy_session;
27 local s2s_mark_connected = require "core.s2smanager".mark_connected;
23 local uuid_gen = require "util.uuid".generate; 28 local uuid_gen = require "util.uuid".generate;
24 local cert_verify_identity = require "util.x509".verify_identity; 29 local cert_verify_identity = require "util.x509".verify_identity;
25 30
26 local s2sout = module:require("s2sout"); 31 local s2sout = module:require("s2sout");
27 32
39 if not sendq then return; end 44 if not sendq then return; end
40 session.log("info", "sending error replies for "..#sendq.." queued stanzas because of failed outgoing connection to "..tostring(session.to_host)); 45 session.log("info", "sending error replies for "..#sendq.." queued stanzas because of failed outgoing connection to "..tostring(session.to_host));
41 local dummy = { 46 local dummy = {
42 type = "s2sin"; 47 type = "s2sin";
43 send = function(s) 48 send = function(s)
44 (session.log or log)("error", "Replying to to an s2s error reply, please report this! Traceback: %s", get_traceback()); 49 (session.log or log)("error", "Replying to to an s2s error reply, please report this! Traceback: %s", traceback());
45 end; 50 end;
46 dummy = true; 51 dummy = true;
47 }; 52 };
48 for i, data in ipairs(sendq) do 53 for i, data in ipairs(sendq) do
49 local reply = data[2]; 54 local reply = data[2];
79 else host.sendq = { {tostring(stanza), stanza.attr.type ~= "error" and stanza.attr.type ~= "result" and st.reply(stanza)} }; end 84 else host.sendq = { {tostring(stanza), stanza.attr.type ~= "error" and stanza.attr.type ~= "result" and st.reply(stanza)} }; end
80 host.log("debug", "stanza [%s] queued ", stanza.name); 85 host.log("debug", "stanza [%s] queued ", stanza.name);
81 return true; 86 return true;
82 elseif host.type == "local" or host.type == "component" then 87 elseif host.type == "local" or host.type == "component" then
83 log("error", "Trying to send a stanza to ourselves??") 88 log("error", "Trying to send a stanza to ourselves??")
84 log("error", "Traceback: %s", get_traceback()); 89 log("error", "Traceback: %s", traceback());
85 log("error", "Stanza: %s", tostring(stanza)); 90 log("error", "Stanza: %s", tostring(stanza));
86 return false; 91 return false;
87 else 92 else
88 (host.log or log)("debug", "going to send stanza to "..to_host.." from "..from_host); 93 (host.log or log)("debug", "going to send stanza to "..to_host.." from "..from_host);
89 -- FIXME 94 -- FIXME
440 445
441 function listener.onstatus(conn, status) 446 function listener.onstatus(conn, status)
442 if status == "ssl-handshake-complete" then 447 if status == "ssl-handshake-complete" then
443 local session = sessions[conn]; 448 local session = sessions[conn];
444 if session and session.direction == "outgoing" then 449 if session and session.direction == "outgoing" then
445 local to_host, from_host = session.to_host, session.from_host;
446 session.log("debug", "Sending stream header..."); 450 session.log("debug", "Sending stream header...");
447 session:open_stream(session.from_host, session.to_host); 451 session:open_stream(session.from_host, session.to_host);
448 end 452 end
449 end 453 end
450 end 454 end