core/s2smanager.lua
changeset 360 e918c979ad1a
parent 354 9b461ae785b1
child 434 0d7ba3742f7a
equal deleted inserted replaced
359:8fbfa8f885a6 360:e918c979ad1a
   139 function streamopened(session, attr)
   139 function streamopened(session, attr)
   140 	local send = session.sends2s;
   140 	local send = session.sends2s;
   141 	
   141 	
   142 	session.version = tonumber(attr.version) or 0;
   142 	session.version = tonumber(attr.version) or 0;
   143 	if session.version >= 1.0 and not (attr.to and attr.from) then
   143 	if session.version >= 1.0 and not (attr.to and attr.from) then
   144 		print("to: "..tostring(attr.to).." from: "..tostring(attr.from));
   144 		--print("to: "..tostring(attr.to).." from: "..tostring(attr.from));
   145 		log("warn", (session.to_host or "(unknown)").." failed to specify 'to' or 'from' hostname as per RFC");
   145 		log("warn", (session.to_host or "(unknown)").." failed to specify 'to' or 'from' hostname as per RFC");
   146 	end
   146 	end
   147 	
   147 	
   148 	if session.direction == "incoming" then
   148 	if session.direction == "incoming" then
   149 		-- Send a reply stream header
   149 		-- Send a reply stream header
   150 		
   150 		
   151 		for k,v in pairs(attr) do print("", tostring(k), ":::", tostring(v)); end
   151 		--for k,v in pairs(attr) do print("", tostring(k), ":::", tostring(v)); end
   152 		
   152 		
   153 		session.to_host = attr.to;
   153 		session.to_host = attr.to;
   154 		session.from_host = attr.from;
   154 		session.from_host = attr.from;
   155 	
   155 	
   156 		session.streamid = uuid_gen();
   156 		session.streamid = uuid_gen();
   157 		print(session, session.from_host, "incoming s2s stream opened");
   157 		(session.log or log)("debug", "incoming s2s received <stream:stream>");
   158 		send("<?xml version='1.0'?>");
   158 		send("<?xml version='1.0'?>");
   159 		send(stanza("stream:stream", { xmlns='jabber:server', ["xmlns:db"]='jabber:server:dialback', ["xmlns:stream"]='http://etherx.jabber.org/streams', id=session.streamid, from=session.to_host }):top_tag());
   159 		send(stanza("stream:stream", { xmlns='jabber:server', ["xmlns:db"]='jabber:server:dialback', ["xmlns:stream"]='http://etherx.jabber.org/streams', id=session.streamid, from=session.to_host }):top_tag());
   160 		if session.to_host and not hosts[session.to_host] then
   160 		if session.to_host and not hosts[session.to_host] then
   161 			-- Attempting to connect to a host we don't serve
   161 			-- Attempting to connect to a host we don't serve
   162 			session:close("host-unknown");
   162 			session:close("host-unknown");