plugins/mod_c2s.lua
changeset 8849 7ec098b68042
parent 8822 780d728f969f
parent 8847 29c6d2681bad
child 8850 74526c425dec
equal deleted inserted replaced
8845:463505cc75d5 8849:7ec098b68042
    47 --- Stream events handlers
    47 --- Stream events handlers
    48 local stream_xmlns_attr = {xmlns='urn:ietf:params:xml:ns:xmpp-streams'};
    48 local stream_xmlns_attr = {xmlns='urn:ietf:params:xml:ns:xmpp-streams'};
    49 
    49 
    50 function stream_callbacks.streamopened(session, attr)
    50 function stream_callbacks.streamopened(session, attr)
    51 	local send = session.send;
    51 	local send = session.send;
    52 	session.host = nameprep(attr.to);
    52 	local host = nameprep(attr.to);
    53 	if not session.host then
    53 	if not host then
    54 		session:close{ condition = "improper-addressing",
    54 		session:close{ condition = "improper-addressing",
    55 			text = "A valid 'to' attribute is required on stream headers" };
    55 			text = "A valid 'to' attribute is required on stream headers" };
       
    56 		return;
       
    57 	end
       
    58 	if not session.host then
       
    59 		session.host = host;
       
    60 	elseif session.host ~= host then
       
    61 		session:close{ condition = "not-authorized",
       
    62 			text = "The 'to' attribute must remain the same across stream restarts" };
    56 		return;
    63 		return;
    57 	end
    64 	end
    58 	session.version = tonumber(attr.version) or 0;
    65 	session.version = tonumber(attr.version) or 0;
    59 	session.streamid = uuid_generate();
    66 	session.streamid = uuid_generate();
    60 	(session.log or session)("debug", "Client sent opening <stream:stream> to %s", session.host);
    67 	(session.log or session)("debug", "Client sent opening <stream:stream> to %s", session.host);