Software /
code /
prosody
Comparison
plugins/mod_s2s/mod_s2s.lua @ 4819:4fa47fc6f20c
mod_s2s: Add session.send() only to incoming streams, and fire the route/remote event on the host (not global anymore)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 04 May 2012 02:22:26 +0100 |
parent | 4818:3bda6fc02652 |
child | 4820:c65edd3bb334 |
comparison
equal
deleted
inserted
replaced
4818:3bda6fc02652 | 4819:4fa47fc6f20c |
---|---|
248 end | 248 end |
249 | 249 |
250 log("debug", "Sending stream features: %s", tostring(features)); | 250 log("debug", "Sending stream features: %s", tostring(features)); |
251 send(features); | 251 send(features); |
252 end | 252 end |
253 | |
254 local host_session = hosts[session.to_host]; | |
255 session.send = function(stanza) | |
256 host_session.events.fire_event("route/remote", { from_host = session.to_host, to_host = session.from_host, stanza = stanza}) | |
257 end; | |
253 elseif session.direction == "outgoing" then | 258 elseif session.direction == "outgoing" then |
254 -- If we are just using the connection for verifying dialback keys, we won't try and auth it | 259 -- If we are just using the connection for verifying dialback keys, we won't try and auth it |
255 if not attr.id then error("stream response did not give us a streamid!!!"); end | 260 if not attr.id then error("stream response did not give us a streamid!!!"); end |
256 session.streamid = attr.id; | 261 session.streamid = attr.id; |
257 | 262 |
279 s2s_mark_connected(session); | 284 s2s_mark_connected(session); |
280 end | 285 end |
281 end | 286 end |
282 end | 287 end |
283 session.notopen = nil; | 288 session.notopen = nil; |
284 session.send = function(stanza) prosody.events.fire_event("route/remote", { from_host = session.to_host, to_host = session.from_host, stanza = stanza}) end; | |
285 end | 289 end |
286 | 290 |
287 function stream_callbacks.streamclosed(session) | 291 function stream_callbacks.streamclosed(session) |
288 (session.log or log)("debug", "Received </stream:stream>"); | 292 (session.log or log)("debug", "Received </stream:stream>"); |
289 session:close(); | 293 session:close(); |