Software /
code /
prosody
Comparison
net/xmppserver_listener.lua @ 3753:f66206484528
net.xmppserver_listener: Made some globals local.
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Wed, 15 Dec 2010 03:52:56 +0500 |
parent | 3634:0d6b57edb7bd |
child | 3754:348cd50980dd |
comparison
equal
deleted
inserted
replaced
3752:c34a58c3ea43 | 3753:f66206484528 |
---|---|
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 | 9 |
10 local tostring = tostring; | |
11 local type = type; | |
12 local xpcall = xpcall; | |
13 local s_format = string.format; | |
14 local traceback = debug.traceback; | |
10 | 15 |
11 local logger = require "logger"; | 16 local logger = require "logger"; |
12 local log = logger.init("xmppserver_listener"); | 17 local log = logger.init("xmppserver_listener"); |
13 local lxp = require "lxp" | 18 local lxp = require "lxp" |
14 local new_xmpp_stream = require "util.xmppstream".new; | 19 local new_xmpp_stream = require "util.xmppstream".new; |
46 session.log("info", "Session closed by remote with error: %s", text); | 51 session.log("info", "Session closed by remote with error: %s", text); |
47 session:close(nil, text); | 52 session:close(nil, text); |
48 end | 53 end |
49 end | 54 end |
50 | 55 |
51 local function handleerr(err) log("error", "Traceback[s2s]: %s: %s", tostring(err), debug.traceback()); end | 56 local function handleerr(err) log("error", "Traceback[s2s]: %s: %s", tostring(err), traceback()); end |
52 function stream_callbacks.handlestanza(session, stanza) | 57 function stream_callbacks.handlestanza(session, stanza) |
53 if stanza.attr.xmlns == "jabber:client" then --COMPAT: Prosody pre-0.6.2 may send jabber:client | 58 if stanza.attr.xmlns == "jabber:client" then --COMPAT: Prosody pre-0.6.2 may send jabber:client |
54 stanza.attr.xmlns = nil; | 59 stanza.attr.xmlns = nil; |
55 end | 60 end |
56 stanza = session.filter("stanzas/in", stanza); | 61 stanza = session.filter("stanzas/in", stanza); |
171 | 176 |
172 function xmppserver.onstatus(conn, status) | 177 function xmppserver.onstatus(conn, status) |
173 if status == "ssl-handshake-complete" then | 178 if status == "ssl-handshake-complete" then |
174 local session = sessions[conn]; | 179 local session = sessions[conn]; |
175 if session and session.direction == "outgoing" then | 180 if session and session.direction == "outgoing" then |
176 local format, to_host, from_host = string.format, session.to_host, session.from_host; | 181 local to_host, from_host = session.to_host, session.from_host; |
177 session.log("debug", "Sending stream header..."); | 182 session.log("debug", "Sending stream header..."); |
178 session.sends2s(format([[<stream:stream xmlns='jabber:server' xmlns:db='jabber:server:dialback' xmlns:stream='http://etherx.jabber.org/streams' from='%s' to='%s' version='1.0'>]], from_host, to_host)); | 183 session.sends2s(s_format([[<stream:stream xmlns='jabber:server' xmlns:db='jabber:server:dialback' xmlns:stream='http://etherx.jabber.org/streams' from='%s' to='%s' version='1.0'>]], from_host, to_host)); |
179 end | 184 end |
180 end | 185 end |
181 end | 186 end |
182 | 187 |
183 function xmppserver.ondisconnect(conn, err) | 188 function xmppserver.ondisconnect(conn, err) |