plugins/mod_c2s.lua
author Matthew Wild <mwild1@gmail.com>
Mon, 22 Apr 2013 12:35:52 +0100
changeset 5508 b7a8615e2be1
parent 5370 7838acadb0fa
child 5518 0220093e34fa
permissions -rw-r--r--
mod_c2s, mod_s2s, net.http, net.http.server: Improve tracebacks (omit traceback function), to make it clearer where an error occured
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4543
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
     1
-- Prosody IM
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
     2
-- Copyright (C) 2008-2010 Matthew Wild
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
     3
-- Copyright (C) 2008-2010 Waqas Hussain
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
     4
-- 
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
     5
-- This project is MIT/X11 licensed. Please see the
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
     6
-- COPYING file in the source package for more information.
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
     7
--
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
     8
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
     9
module:set_global();
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    10
4548
e6e5c76ff009 sessionmanager, mod_c2s: Move timeout logic to mod_c2s
Matthew Wild <mwild1@gmail.com>
parents: 4543
diff changeset
    11
local add_task = require "util.timer".add_task;
4543
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    12
local new_xmpp_stream = require "util.xmppstream".new;
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    13
local nameprep = require "util.encodings".stringprep.nameprep;
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    14
local sessionmanager = require "core.sessionmanager";
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    15
local st = require "util.stanza";
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    16
local sm_new_session, sm_destroy_session = sessionmanager.new_session, sessionmanager.destroy_session;
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    17
local uuid_generate = require "util.uuid".generate;
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    18
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    19
local xpcall, tostring, type = xpcall, tostring, type;
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    20
local traceback = debug.traceback;
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    21
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    22
local xmlns_xmpp_streams = "urn:ietf:params:xml:ns:xmpp-streams";
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    23
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    24
local log = module._log;
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    25
4548
e6e5c76ff009 sessionmanager, mod_c2s: Move timeout logic to mod_c2s
Matthew Wild <mwild1@gmail.com>
parents: 4543
diff changeset
    26
local c2s_timeout = module:get_option_number("c2s_timeout");
4964
c9b8ec3eb1e9 mod_c2s: Don't call ondisconnect manually on close, it is now called by net.server. Replace with inline code for destroying the session, and also waiting for a reply </stream:stream> if there is a chance of further data sent by the client. session.send() on a half-closed stream returns false (and does not deliver the data).
Matthew Wild <mwild1@gmail.com>
parents: 4852
diff changeset
    27
local stream_close_timeout = module:get_option_number("c2s_close_timeout", 5);
4543
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    28
local opt_keepalives = module:get_option_boolean("tcp_keepalives", false);
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    29
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    30
local sessions = module:shared("sessions");
5013
ab693eea0869 mod_admin_adhoc, mod_admin_telnet, mod_bosh, mod_c2s, mod_component, mod_pep, mod_presence, mod_roster, mod_s2s: Import core_post_stanza from the global prosody table.
Kim Alvefur <zash@zash.se>
parents: 4996
diff changeset
    31
local core_process_stanza = prosody.core_process_stanza;
5370
7838acadb0fa mod_announce, mod_auth_anonymous, mod_c2s, mod_c2s, mod_component, mod_iq, mod_message, mod_presence, mod_tls: Access prosody.{hosts,bare_sessions,full_sessions} instead of the old globals
Kim Alvefur <zash@zash.se>
parents: 5281
diff changeset
    32
local hosts = prosody.hosts;
4543
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    33
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    34
local stream_callbacks = { default_ns = "jabber:client", handlestanza = core_process_stanza };
4625
325965bafae1 mod_c2s, mod_s2s: Drop default_port and default_mode from listener objects (default_port is deprecated, and default_mode already defaults to *a)
Matthew Wild <mwild1@gmail.com>
parents: 4620
diff changeset
    35
local listener = {};
4543
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    36
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    37
--- Stream events handlers
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    38
local stream_xmlns_attr = {xmlns='urn:ietf:params:xml:ns:xmpp-streams'};
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    39
local default_stream_attr = { ["xmlns:stream"] = "http://etherx.jabber.org/streams", xmlns = stream_callbacks.default_ns, version = "1.0", id = "" };
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    40
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    41
function stream_callbacks.streamopened(session, attr)
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    42
	local send = session.send;
4551
8f25f3b1c62f mod_c2s: Code reduction
Matthew Wild <mwild1@gmail.com>
parents: 4548
diff changeset
    43
	session.host = nameprep(attr.to);
4543
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    44
	if not session.host then
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    45
		session:close{ condition = "improper-addressing",
4551
8f25f3b1c62f mod_c2s: Code reduction
Matthew Wild <mwild1@gmail.com>
parents: 4548
diff changeset
    46
			text = "A valid 'to' attribute is required on stream headers" };
4543
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    47
		return;
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    48
	end
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    49
	session.version = tonumber(attr.version) or 0;
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    50
	session.streamid = uuid_generate();
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    51
	(session.log or session)("debug", "Client sent opening <stream:stream> to %s", session.host);
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    52
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    53
	if not hosts[session.host] then
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    54
		-- We don't serve this host...
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    55
		session:close{ condition = "host-unknown", text = "This server does not serve "..tostring(session.host)};
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    56
		return;
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    57
	end
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    58
4852
9cc934f49df0 mod_c2s: Another lurking string.format squashed.
Matthew Wild <mwild1@gmail.com>
parents: 4753
diff changeset
    59
	send("<?xml version='1.0'?>"..st.stanza("stream:stream", {
9cc934f49df0 mod_c2s: Another lurking string.format squashed.
Matthew Wild <mwild1@gmail.com>
parents: 4753
diff changeset
    60
		xmlns = 'jabber:client', ["xmlns:stream"] = 'http://etherx.jabber.org/streams';
9cc934f49df0 mod_c2s: Another lurking string.format squashed.
Matthew Wild <mwild1@gmail.com>
parents: 4753
diff changeset
    61
		id = session.streamid, from = session.host, version = '1.0', ["xml:lang"] = 'en' }):top_tag());
4543
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    62
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    63
	(session.log or log)("debug", "Sent reply <stream:stream> to client");
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    64
	session.notopen = nil;
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    65
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    66
	-- If session.secure is *false* (not nil) then it means we /were/ encrypting
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    67
	-- since we now have a new stream header, session is secured
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    68
	if session.secure == false then
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    69
		session.secure = true;
5228
edabb34417b7 mod_c2s: Check if TLS compression is used
Kim Alvefur <zash@zash.se>
parents: 5120
diff changeset
    70
edabb34417b7 mod_c2s: Check if TLS compression is used
Kim Alvefur <zash@zash.se>
parents: 5120
diff changeset
    71
		-- Check if TLS compression is used
edabb34417b7 mod_c2s: Check if TLS compression is used
Kim Alvefur <zash@zash.se>
parents: 5120
diff changeset
    72
		local sock = session.conn:socket();
edabb34417b7 mod_c2s: Check if TLS compression is used
Kim Alvefur <zash@zash.se>
parents: 5120
diff changeset
    73
		if sock.info then
edabb34417b7 mod_c2s: Check if TLS compression is used
Kim Alvefur <zash@zash.se>
parents: 5120
diff changeset
    74
			session.compressed = sock:info"compression";
edabb34417b7 mod_c2s: Check if TLS compression is used
Kim Alvefur <zash@zash.se>
parents: 5120
diff changeset
    75
		elseif sock.compression then
edabb34417b7 mod_c2s: Check if TLS compression is used
Kim Alvefur <zash@zash.se>
parents: 5120
diff changeset
    76
			session.compressed = sock:compression(); --COMPAT mw/luasec-hg
edabb34417b7 mod_c2s: Check if TLS compression is used
Kim Alvefur <zash@zash.se>
parents: 5120
diff changeset
    77
		end
4543
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    78
	end
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    79
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    80
	local features = st.stanza("stream:features");
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    81
	hosts[session.host].events.fire_event("stream-features", { origin = session, features = features });
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    82
	module:fire_event("stream-features", session, features);
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    83
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    84
	send(features);
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    85
end
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    86
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    87
function stream_callbacks.streamclosed(session)
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    88
	session.log("debug", "Received </stream:stream>");
4986
9da430b69f13 mod_c2s: Change 'reason' parameter of session:close() to take nil to mean 'graceful close initiated by us' and false for 'graceful close initiated by client'
Matthew Wild <mwild1@gmail.com>
parents: 4964
diff changeset
    89
	session:close(false);
4543
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    90
end
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    91
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    92
function stream_callbacks.error(session, error, data)
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    93
	if error == "no-stream" then
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    94
		session.log("debug", "Invalid opening stream header");
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    95
		session:close("invalid-namespace");
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    96
	elseif error == "parse-error" then
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    97
		(session.log or log)("debug", "Client XML parse error: %s", tostring(data));
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    98
		session:close("not-well-formed");
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    99
	elseif error == "stream-error" then
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   100
		local condition, text = "undefined-condition";
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   101
		for child in data:children() do
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   102
			if child.attr.xmlns == xmlns_xmpp_streams then
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   103
				if child.name ~= "text" then
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   104
					condition = child.name;
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   105
				else
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   106
					text = child:get_text();
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   107
				end
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   108
				if condition ~= "undefined-condition" and text then
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   109
					break;
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   110
				end
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   111
			end
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   112
		end
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   113
		text = condition .. (text and (" ("..text..")") or "");
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   114
		session.log("info", "Session closed by remote with error: %s", text);
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   115
		session:close(nil, text);
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   116
	end
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   117
end
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   118
5508
b7a8615e2be1 mod_c2s, mod_s2s, net.http, net.http.server: Improve tracebacks (omit traceback function), to make it clearer where an error occured
Matthew Wild <mwild1@gmail.com>
parents: 5370
diff changeset
   119
local function handleerr(err) log("error", "Traceback[c2s]: %s", traceback(tostring(err), 2)); end
4543
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   120
function stream_callbacks.handlestanza(session, stanza)
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   121
	stanza = session.filter("stanzas/in", stanza);
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   122
	if stanza then
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   123
		return xpcall(function () return core_process_stanza(session, stanza) end, handleerr);
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   124
	end
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   125
end
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   126
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   127
--- Session methods
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   128
local function session_close(session, reason)
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   129
	local log = session.log or log;
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   130
	if session.conn then
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   131
		if session.notopen then
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   132
			session.send("<?xml version='1.0'?>");
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   133
			session.send(st.stanza("stream:stream", default_stream_attr):top_tag());
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   134
		end
4986
9da430b69f13 mod_c2s: Change 'reason' parameter of session:close() to take nil to mean 'graceful close initiated by us' and false for 'graceful close initiated by client'
Matthew Wild <mwild1@gmail.com>
parents: 4964
diff changeset
   135
		if reason then -- nil == no err, initiated by us, false == initiated by client
4543
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   136
			if type(reason) == "string" then -- assume stream error
4996
164dc19519d8 mod_c2s, mod_s2s: Lower 'Disconnecting X' log messages from 'info' to 'debug'
Matthew Wild <mwild1@gmail.com>
parents: 4986
diff changeset
   137
				log("debug", "Disconnecting client, <stream:error> is: %s", reason);
4543
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   138
				session.send(st.stanza("stream:error"):tag(reason, {xmlns = 'urn:ietf:params:xml:ns:xmpp-streams' }));
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   139
			elseif type(reason) == "table" then
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   140
				if reason.condition then
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   141
					local stanza = st.stanza("stream:error"):tag(reason.condition, stream_xmlns_attr):up();
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   142
					if reason.text then
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   143
						stanza:tag("text", stream_xmlns_attr):text(reason.text):up();
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   144
					end
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   145
					if reason.extra then
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   146
						stanza:add_child(reason.extra);
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   147
					end
4996
164dc19519d8 mod_c2s, mod_s2s: Lower 'Disconnecting X' log messages from 'info' to 'debug'
Matthew Wild <mwild1@gmail.com>
parents: 4986
diff changeset
   148
					log("debug", "Disconnecting client, <stream:error> is: %s", tostring(stanza));
4543
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   149
					session.send(stanza);
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   150
				elseif reason.name then -- a stanza
4996
164dc19519d8 mod_c2s, mod_s2s: Lower 'Disconnecting X' log messages from 'info' to 'debug'
Matthew Wild <mwild1@gmail.com>
parents: 4986
diff changeset
   151
					log("debug", "Disconnecting client, <stream:error> is: %s", tostring(reason));
4543
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   152
					session.send(reason);
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   153
				end
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   154
			end
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   155
		end
4986
9da430b69f13 mod_c2s: Change 'reason' parameter of session:close() to take nil to mean 'graceful close initiated by us' and false for 'graceful close initiated by client'
Matthew Wild <mwild1@gmail.com>
parents: 4964
diff changeset
   156
		
4543
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   157
		session.send("</stream:stream>");
4964
c9b8ec3eb1e9 mod_c2s: Don't call ondisconnect manually on close, it is now called by net.server. Replace with inline code for destroying the session, and also waiting for a reply </stream:stream> if there is a chance of further data sent by the client. session.send() on a half-closed stream returns false (and does not deliver the data).
Matthew Wild <mwild1@gmail.com>
parents: 4852
diff changeset
   158
		function session.send() return false; end
c9b8ec3eb1e9 mod_c2s: Don't call ondisconnect manually on close, it is now called by net.server. Replace with inline code for destroying the session, and also waiting for a reply </stream:stream> if there is a chance of further data sent by the client. session.send() on a half-closed stream returns false (and does not deliver the data).
Matthew Wild <mwild1@gmail.com>
parents: 4852
diff changeset
   159
		
4986
9da430b69f13 mod_c2s: Change 'reason' parameter of session:close() to take nil to mean 'graceful close initiated by us' and false for 'graceful close initiated by client'
Matthew Wild <mwild1@gmail.com>
parents: 4964
diff changeset
   160
		local reason = (reason and (reason.text or reason.condition)) or reason;
9da430b69f13 mod_c2s: Change 'reason' parameter of session:close() to take nil to mean 'graceful close initiated by us' and false for 'graceful close initiated by client'
Matthew Wild <mwild1@gmail.com>
parents: 4964
diff changeset
   161
		session.log("info", "c2s stream for %s closed: %s", session.full_jid or ("<"..session.ip..">"), reason or "session closed");
4964
c9b8ec3eb1e9 mod_c2s: Don't call ondisconnect manually on close, it is now called by net.server. Replace with inline code for destroying the session, and also waiting for a reply </stream:stream> if there is a chance of further data sent by the client. session.send() on a half-closed stream returns false (and does not deliver the data).
Matthew Wild <mwild1@gmail.com>
parents: 4852
diff changeset
   162
c9b8ec3eb1e9 mod_c2s: Don't call ondisconnect manually on close, it is now called by net.server. Replace with inline code for destroying the session, and also waiting for a reply </stream:stream> if there is a chance of further data sent by the client. session.send() on a half-closed stream returns false (and does not deliver the data).
Matthew Wild <mwild1@gmail.com>
parents: 4852
diff changeset
   163
		-- Authenticated incoming stream may still be sending us stanzas, so wait for </stream:stream> from remote
c9b8ec3eb1e9 mod_c2s: Don't call ondisconnect manually on close, it is now called by net.server. Replace with inline code for destroying the session, and also waiting for a reply </stream:stream> if there is a chance of further data sent by the client. session.send() on a half-closed stream returns false (and does not deliver the data).
Matthew Wild <mwild1@gmail.com>
parents: 4852
diff changeset
   164
		local conn = session.conn;
4986
9da430b69f13 mod_c2s: Change 'reason' parameter of session:close() to take nil to mean 'graceful close initiated by us' and false for 'graceful close initiated by client'
Matthew Wild <mwild1@gmail.com>
parents: 4964
diff changeset
   165
		if reason == nil and not session.notopen and session.type == "c2s" then
4964
c9b8ec3eb1e9 mod_c2s: Don't call ondisconnect manually on close, it is now called by net.server. Replace with inline code for destroying the session, and also waiting for a reply </stream:stream> if there is a chance of further data sent by the client. session.send() on a half-closed stream returns false (and does not deliver the data).
Matthew Wild <mwild1@gmail.com>
parents: 4852
diff changeset
   166
			-- Grace time to process data from authenticated cleanly-closed stream
c9b8ec3eb1e9 mod_c2s: Don't call ondisconnect manually on close, it is now called by net.server. Replace with inline code for destroying the session, and also waiting for a reply </stream:stream> if there is a chance of further data sent by the client. session.send() on a half-closed stream returns false (and does not deliver the data).
Matthew Wild <mwild1@gmail.com>
parents: 4852
diff changeset
   167
			add_task(stream_close_timeout, function ()
c9b8ec3eb1e9 mod_c2s: Don't call ondisconnect manually on close, it is now called by net.server. Replace with inline code for destroying the session, and also waiting for a reply </stream:stream> if there is a chance of further data sent by the client. session.send() on a half-closed stream returns false (and does not deliver the data).
Matthew Wild <mwild1@gmail.com>
parents: 4852
diff changeset
   168
				if not session.destroyed then
c9b8ec3eb1e9 mod_c2s: Don't call ondisconnect manually on close, it is now called by net.server. Replace with inline code for destroying the session, and also waiting for a reply </stream:stream> if there is a chance of further data sent by the client. session.send() on a half-closed stream returns false (and does not deliver the data).
Matthew Wild <mwild1@gmail.com>
parents: 4852
diff changeset
   169
					session.log("warn", "Failed to receive a stream close response, closing connection anyway...");
c9b8ec3eb1e9 mod_c2s: Don't call ondisconnect manually on close, it is now called by net.server. Replace with inline code for destroying the session, and also waiting for a reply </stream:stream> if there is a chance of further data sent by the client. session.send() on a half-closed stream returns false (and does not deliver the data).
Matthew Wild <mwild1@gmail.com>
parents: 4852
diff changeset
   170
					sm_destroy_session(session, reason);
c9b8ec3eb1e9 mod_c2s: Don't call ondisconnect manually on close, it is now called by net.server. Replace with inline code for destroying the session, and also waiting for a reply </stream:stream> if there is a chance of further data sent by the client. session.send() on a half-closed stream returns false (and does not deliver the data).
Matthew Wild <mwild1@gmail.com>
parents: 4852
diff changeset
   171
					conn:close();
c9b8ec3eb1e9 mod_c2s: Don't call ondisconnect manually on close, it is now called by net.server. Replace with inline code for destroying the session, and also waiting for a reply </stream:stream> if there is a chance of further data sent by the client. session.send() on a half-closed stream returns false (and does not deliver the data).
Matthew Wild <mwild1@gmail.com>
parents: 4852
diff changeset
   172
				end
c9b8ec3eb1e9 mod_c2s: Don't call ondisconnect manually on close, it is now called by net.server. Replace with inline code for destroying the session, and also waiting for a reply </stream:stream> if there is a chance of further data sent by the client. session.send() on a half-closed stream returns false (and does not deliver the data).
Matthew Wild <mwild1@gmail.com>
parents: 4852
diff changeset
   173
			end);
c9b8ec3eb1e9 mod_c2s: Don't call ondisconnect manually on close, it is now called by net.server. Replace with inline code for destroying the session, and also waiting for a reply </stream:stream> if there is a chance of further data sent by the client. session.send() on a half-closed stream returns false (and does not deliver the data).
Matthew Wild <mwild1@gmail.com>
parents: 4852
diff changeset
   174
		else
c9b8ec3eb1e9 mod_c2s: Don't call ondisconnect manually on close, it is now called by net.server. Replace with inline code for destroying the session, and also waiting for a reply </stream:stream> if there is a chance of further data sent by the client. session.send() on a half-closed stream returns false (and does not deliver the data).
Matthew Wild <mwild1@gmail.com>
parents: 4852
diff changeset
   175
			sm_destroy_session(session, reason);
c9b8ec3eb1e9 mod_c2s: Don't call ondisconnect manually on close, it is now called by net.server. Replace with inline code for destroying the session, and also waiting for a reply </stream:stream> if there is a chance of further data sent by the client. session.send() on a half-closed stream returns false (and does not deliver the data).
Matthew Wild <mwild1@gmail.com>
parents: 4852
diff changeset
   176
			conn:close();
c9b8ec3eb1e9 mod_c2s: Don't call ondisconnect manually on close, it is now called by net.server. Replace with inline code for destroying the session, and also waiting for a reply </stream:stream> if there is a chance of further data sent by the client. session.send() on a half-closed stream returns false (and does not deliver the data).
Matthew Wild <mwild1@gmail.com>
parents: 4852
diff changeset
   177
		end
4543
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   178
	end
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   179
end
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   180
5097
6c52a7a881cc mod_c2s: When a user gets deleted, drop all their sessions
Kim Alvefur <zash@zash.se>
parents: 5013
diff changeset
   181
module:hook_global("user-deleted", function(event)
6c52a7a881cc mod_c2s: When a user gets deleted, drop all their sessions
Kim Alvefur <zash@zash.se>
parents: 5013
diff changeset
   182
	local username, host = event.username, event.host;
6c52a7a881cc mod_c2s: When a user gets deleted, drop all their sessions
Kim Alvefur <zash@zash.se>
parents: 5013
diff changeset
   183
	local user = hosts[host].sessions[username];
6c52a7a881cc mod_c2s: When a user gets deleted, drop all their sessions
Kim Alvefur <zash@zash.se>
parents: 5013
diff changeset
   184
	if user and user.sessions then
6c52a7a881cc mod_c2s: When a user gets deleted, drop all their sessions
Kim Alvefur <zash@zash.se>
parents: 5013
diff changeset
   185
		for jid, session in pairs(user.sessions) do
6c52a7a881cc mod_c2s: When a user gets deleted, drop all their sessions
Kim Alvefur <zash@zash.se>
parents: 5013
diff changeset
   186
			session:close{ condition = "not-authorized", text = "Account deleted" };
6c52a7a881cc mod_c2s: When a user gets deleted, drop all their sessions
Kim Alvefur <zash@zash.se>
parents: 5013
diff changeset
   187
		end
6c52a7a881cc mod_c2s: When a user gets deleted, drop all their sessions
Kim Alvefur <zash@zash.se>
parents: 5013
diff changeset
   188
	end
6c52a7a881cc mod_c2s: When a user gets deleted, drop all their sessions
Kim Alvefur <zash@zash.se>
parents: 5013
diff changeset
   189
end, 200);
6c52a7a881cc mod_c2s: When a user gets deleted, drop all their sessions
Kim Alvefur <zash@zash.se>
parents: 5013
diff changeset
   190
4543
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   191
--- Port listener
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   192
function listener.onconnect(conn)
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   193
	local session = sm_new_session(conn);
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   194
	sessions[conn] = session;
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   195
	
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   196
	session.log("info", "Client connected");
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   197
	
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   198
	-- Client is using legacy SSL (otherwise mod_tls sets this flag)
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   199
	if conn:ssl() then
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   200
		session.secure = true;
5228
edabb34417b7 mod_c2s: Check if TLS compression is used
Kim Alvefur <zash@zash.se>
parents: 5120
diff changeset
   201
edabb34417b7 mod_c2s: Check if TLS compression is used
Kim Alvefur <zash@zash.se>
parents: 5120
diff changeset
   202
		-- Check if TLS compression is used
edabb34417b7 mod_c2s: Check if TLS compression is used
Kim Alvefur <zash@zash.se>
parents: 5120
diff changeset
   203
		local sock = conn:socket();
edabb34417b7 mod_c2s: Check if TLS compression is used
Kim Alvefur <zash@zash.se>
parents: 5120
diff changeset
   204
		if sock.info then
edabb34417b7 mod_c2s: Check if TLS compression is used
Kim Alvefur <zash@zash.se>
parents: 5120
diff changeset
   205
			session.compressed = sock:info"compression";
edabb34417b7 mod_c2s: Check if TLS compression is used
Kim Alvefur <zash@zash.se>
parents: 5120
diff changeset
   206
		elseif sock.compression then
edabb34417b7 mod_c2s: Check if TLS compression is used
Kim Alvefur <zash@zash.se>
parents: 5120
diff changeset
   207
			session.compressed = sock:compression(); --COMPAT mw/luasec-hg
edabb34417b7 mod_c2s: Check if TLS compression is used
Kim Alvefur <zash@zash.se>
parents: 5120
diff changeset
   208
		end
4543
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   209
	end
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   210
	
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   211
	if opt_keepalives then
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   212
		conn:setoption("keepalive", opt_keepalives);
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   213
	end
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   214
	
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   215
	session.close = session_close;
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   216
	
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   217
	local stream = new_xmpp_stream(session, stream_callbacks);
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   218
	session.stream = stream;
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   219
	session.notopen = true;
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   220
	
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   221
	function session.reset_stream()
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   222
		session.notopen = true;
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   223
		session.stream:reset();
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   224
	end
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   225
	
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   226
	local filter = session.filter;
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   227
	function session.data(data)
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   228
		data = filter("bytes/in", data);
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   229
		if data then
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   230
			local ok, err = stream:feed(data);
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   231
			if ok then return; end
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   232
			log("debug", "Received invalid XML (%s) %d bytes: %s", tostring(err), #data, data:sub(1, 300):gsub("[\r\n]+", " "):gsub("[%z\1-\31]", "_"));
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   233
			session:close("not-well-formed");
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   234
		end
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   235
	end
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   236
4548
e6e5c76ff009 sessionmanager, mod_c2s: Move timeout logic to mod_c2s
Matthew Wild <mwild1@gmail.com>
parents: 4543
diff changeset
   237
	
e6e5c76ff009 sessionmanager, mod_c2s: Move timeout logic to mod_c2s
Matthew Wild <mwild1@gmail.com>
parents: 4543
diff changeset
   238
	if c2s_timeout then
e6e5c76ff009 sessionmanager, mod_c2s: Move timeout logic to mod_c2s
Matthew Wild <mwild1@gmail.com>
parents: 4543
diff changeset
   239
		add_task(c2s_timeout, function ()
e6e5c76ff009 sessionmanager, mod_c2s: Move timeout logic to mod_c2s
Matthew Wild <mwild1@gmail.com>
parents: 4543
diff changeset
   240
			if session.type == "c2s_unauthed" then
e6e5c76ff009 sessionmanager, mod_c2s: Move timeout logic to mod_c2s
Matthew Wild <mwild1@gmail.com>
parents: 4543
diff changeset
   241
				session:close("connection-timeout");
e6e5c76ff009 sessionmanager, mod_c2s: Move timeout logic to mod_c2s
Matthew Wild <mwild1@gmail.com>
parents: 4543
diff changeset
   242
			end
e6e5c76ff009 sessionmanager, mod_c2s: Move timeout logic to mod_c2s
Matthew Wild <mwild1@gmail.com>
parents: 4543
diff changeset
   243
		end);
e6e5c76ff009 sessionmanager, mod_c2s: Move timeout logic to mod_c2s
Matthew Wild <mwild1@gmail.com>
parents: 4543
diff changeset
   244
	end
e6e5c76ff009 sessionmanager, mod_c2s: Move timeout logic to mod_c2s
Matthew Wild <mwild1@gmail.com>
parents: 4543
diff changeset
   245
4543
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   246
	session.dispatch_stanza = stream_callbacks.handlestanza;
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   247
end
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   248
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   249
function listener.onincoming(conn, data)
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   250
	local session = sessions[conn];
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   251
	if session then
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   252
		session.data(data);
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   253
	end
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   254
end
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   255
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   256
function listener.ondisconnect(conn, err)
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   257
	local session = sessions[conn];
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   258
	if session then
4964
c9b8ec3eb1e9 mod_c2s: Don't call ondisconnect manually on close, it is now called by net.server. Replace with inline code for destroying the session, and also waiting for a reply </stream:stream> if there is a chance of further data sent by the client. session.send() on a half-closed stream returns false (and does not deliver the data).
Matthew Wild <mwild1@gmail.com>
parents: 4852
diff changeset
   259
		(session.log or log)("info", "Client disconnected: %s", err or "connection closed");
4543
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   260
		sm_destroy_session(session, err);
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   261
		sessions[conn]  = nil;
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   262
	end
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   263
end
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   264
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   265
function listener.associate_session(conn, session)
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   266
	sessions[conn] = session;
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   267
end
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   268
5281
815c689f85ad prosody, mod_c2s, mod_s2s: Move closing of c2s and s2s sessions to respective plugins
Kim Alvefur <zash@zash.se>
parents: 5228
diff changeset
   269
module:hook("server-stopping", function(event)
815c689f85ad prosody, mod_c2s, mod_s2s: Move closing of c2s and s2s sessions to respective plugins
Kim Alvefur <zash@zash.se>
parents: 5228
diff changeset
   270
	local reason = event.reason;
815c689f85ad prosody, mod_c2s, mod_s2s: Move closing of c2s and s2s sessions to respective plugins
Kim Alvefur <zash@zash.se>
parents: 5228
diff changeset
   271
	for _, session in pairs(sessions) do
815c689f85ad prosody, mod_c2s, mod_s2s: Move closing of c2s and s2s sessions to respective plugins
Kim Alvefur <zash@zash.se>
parents: 5228
diff changeset
   272
		session:close{ condition = "system-shutdown", text = reason };
815c689f85ad prosody, mod_c2s, mod_s2s: Move closing of c2s and s2s sessions to respective plugins
Kim Alvefur <zash@zash.se>
parents: 5228
diff changeset
   273
	end
815c689f85ad prosody, mod_c2s, mod_s2s: Move closing of c2s and s2s sessions to respective plugins
Kim Alvefur <zash@zash.se>
parents: 5228
diff changeset
   274
end, 1000);
815c689f85ad prosody, mod_c2s, mod_s2s: Move closing of c2s and s2s sessions to respective plugins
Kim Alvefur <zash@zash.se>
parents: 5228
diff changeset
   275
815c689f85ad prosody, mod_c2s, mod_s2s: Move closing of c2s and s2s sessions to respective plugins
Kim Alvefur <zash@zash.se>
parents: 5228
diff changeset
   276
815c689f85ad prosody, mod_c2s, mod_s2s: Move closing of c2s and s2s sessions to respective plugins
Kim Alvefur <zash@zash.se>
parents: 5228
diff changeset
   277
5120
bcabea740c00 mod_{admin_telnet,c2s,component,http,net_multiplex,s2s}: Use module:provides() instead of module:add_item().
Waqas Hussain <waqas20@gmail.com>
parents: 5097
diff changeset
   278
module:provides("net", {
4610
171051f9dd00 mod_c2s: Use module:add_item() to add the net-provider for portmanager
Matthew Wild <mwild1@gmail.com>
parents: 4551
diff changeset
   279
	name = "c2s";
4543
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   280
	listener = listener;
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   281
	default_port = 5222;
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   282
	encryption = "starttls";
4626
9df9e87d0339 mod_c2s: Add missing multiplexed service discovery pattern.
Kim Alvefur <zash@zash.se>
parents: 4625
diff changeset
   283
	multiplex = {
9df9e87d0339 mod_c2s: Add missing multiplexed service discovery pattern.
Kim Alvefur <zash@zash.se>
parents: 4625
diff changeset
   284
		pattern = "^<.*:stream.*%sxmlns%s*=%s*(['\"])jabber:client%1.*>";
9df9e87d0339 mod_c2s: Add missing multiplexed service discovery pattern.
Kim Alvefur <zash@zash.se>
parents: 4625
diff changeset
   285
	};
4543
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   286
});
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   287
5120
bcabea740c00 mod_{admin_telnet,c2s,component,http,net_multiplex,s2s}: Use module:provides() instead of module:add_item().
Waqas Hussain <waqas20@gmail.com>
parents: 5097
diff changeset
   288
module:provides("net", {
4610
171051f9dd00 mod_c2s: Use module:add_item() to add the net-provider for portmanager
Matthew Wild <mwild1@gmail.com>
parents: 4551
diff changeset
   289
	name = "legacy_ssl";
4543
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   290
	listener = listener;
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   291
	encryption = "ssl";
4620
e9dc6ae68c69 mod_c2s, mod_s2s: Add multiplex support
Matthew Wild <mwild1@gmail.com>
parents: 4610
diff changeset
   292
	multiplex = {
e9dc6ae68c69 mod_c2s, mod_s2s: Add multiplex support
Matthew Wild <mwild1@gmail.com>
parents: 4610
diff changeset
   293
		pattern = "^<.*:stream.*%sxmlns%s*=%s*(['\"])jabber:client%1.*>";
e9dc6ae68c69 mod_c2s, mod_s2s: Add multiplex support
Matthew Wild <mwild1@gmail.com>
parents: 4610
diff changeset
   294
	};
4543
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   295
});
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   296
db27a4c18b6a mod_c2s, sessionmanager, xmppclient_listener: Move all c2s network and stream logic into a new module, mod_c2s
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
   297