Comparison

plugins/mod_c2s.lua @ 4551:8f25f3b1c62f

mod_c2s: Code reduction
author Matthew Wild <mwild1@gmail.com>
date Mon, 23 Jan 2012 02:15:28 +0000
parent 4548:e6e5c76ff009
child 4610:171051f9dd00
comparison
equal deleted inserted replaced
4550:1c41e4a846a2 4551:8f25f3b1c62f
37 local stream_xmlns_attr = {xmlns='urn:ietf:params:xml:ns:xmpp-streams'}; 37 local stream_xmlns_attr = {xmlns='urn:ietf:params:xml:ns:xmpp-streams'};
38 local default_stream_attr = { ["xmlns:stream"] = "http://etherx.jabber.org/streams", xmlns = stream_callbacks.default_ns, version = "1.0", id = "" }; 38 local default_stream_attr = { ["xmlns:stream"] = "http://etherx.jabber.org/streams", xmlns = stream_callbacks.default_ns, version = "1.0", id = "" };
39 39
40 function stream_callbacks.streamopened(session, attr) 40 function stream_callbacks.streamopened(session, attr)
41 local send = session.send; 41 local send = session.send;
42 session.host = attr.to; 42 session.host = nameprep(attr.to);
43 if not session.host then 43 if not session.host then
44 session:close{ condition = "improper-addressing", 44 session:close{ condition = "improper-addressing",
45 text = "A 'to' attribute is required on stream headers" }; 45 text = "A valid 'to' attribute is required on stream headers" };
46 return; 46 return;
47 end 47 end
48 session.host = nameprep(session.host);
49 session.version = tonumber(attr.version) or 0; 48 session.version = tonumber(attr.version) or 0;
50 session.streamid = uuid_generate(); 49 session.streamid = uuid_generate();
51 (session.log or session)("debug", "Client sent opening <stream:stream> to %s", session.host); 50 (session.log or session)("debug", "Client sent opening <stream:stream> to %s", session.host);
52 51
53 if not hosts[session.host] then 52 if not hosts[session.host] then