Software /
code /
prosody
Comparison
plugins/mod_s2s/mod_s2s.lua @ 6683:873ad1023eb0
mod_s2s: Don't cache session.sends2s (or do it later), prevents sending data after session was closed
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 13 May 2015 21:55:08 +0200 |
parent | 6600:b1c84d220c40 |
child | 6684:53635a91c95c |
comparison
equal
deleted
inserted
replaced
6682:63f5870f9afe | 6683:873ad1023eb0 |
---|---|
145 module:hook("s2s-authenticated", make_authenticated, -1); | 145 module:hook("s2s-authenticated", make_authenticated, -1); |
146 end | 146 end |
147 | 147 |
148 -- Stream is authorised, and ready for normal stanzas | 148 -- Stream is authorised, and ready for normal stanzas |
149 function mark_connected(session) | 149 function mark_connected(session) |
150 local sendq, send = session.sendq, session.sends2s; | 150 local sendq = session.sendq; |
151 | 151 |
152 local from, to = session.from_host, session.to_host; | 152 local from, to = session.from_host, session.to_host; |
153 | 153 |
154 session.log("info", "%s s2s connection %s->%s complete", session.direction, from, to); | 154 session.log("info", "%s s2s connection %s->%s complete", session.direction, from, to); |
155 | 155 |
168 end | 168 end |
169 | 169 |
170 if session.direction == "outgoing" then | 170 if session.direction == "outgoing" then |
171 if sendq then | 171 if sendq then |
172 session.log("debug", "sending %d queued stanzas across new outgoing connection to %s", #sendq, session.to_host); | 172 session.log("debug", "sending %d queued stanzas across new outgoing connection to %s", #sendq, session.to_host); |
173 local send = session.sends2s; | |
173 for i, data in ipairs(sendq) do | 174 for i, data in ipairs(sendq) do |
174 send(data[1]); | 175 send(data[1]); |
175 sendq[i] = nil; | 176 sendq[i] = nil; |
176 end | 177 end |
177 session.sendq = nil; | 178 session.sendq = nil; |
267 local stream_callbacks = { default_ns = "jabber:server", handlestanza = core_process_stanza }; | 268 local stream_callbacks = { default_ns = "jabber:server", handlestanza = core_process_stanza }; |
268 | 269 |
269 local xmlns_xmpp_streams = "urn:ietf:params:xml:ns:xmpp-streams"; | 270 local xmlns_xmpp_streams = "urn:ietf:params:xml:ns:xmpp-streams"; |
270 | 271 |
271 function stream_callbacks.streamopened(session, attr) | 272 function stream_callbacks.streamopened(session, attr) |
272 local send = session.sends2s; | |
273 | |
274 session.version = tonumber(attr.version) or 0; | 273 session.version = tonumber(attr.version) or 0; |
275 | 274 |
276 -- TODO: Rename session.secure to session.encrypted | 275 -- TODO: Rename session.secure to session.encrypted |
277 if session.secure == false then | 276 if session.secure == false then |
278 session.secure = true; | 277 session.secure = true; |
358 else | 357 else |
359 (session.log or log)("warn", "No 'to' on stream header from %s means we can't offer any features", from or session.ip or "unknown host"); | 358 (session.log or log)("warn", "No 'to' on stream header from %s means we can't offer any features", from or session.ip or "unknown host"); |
360 end | 359 end |
361 | 360 |
362 log("debug", "Sending stream features: %s", tostring(features)); | 361 log("debug", "Sending stream features: %s", tostring(features)); |
363 send(features); | 362 session.sends2s(features); |
364 end | 363 end |
365 session.notopen = nil; | 364 session.notopen = nil; |
366 elseif session.direction == "outgoing" then | 365 elseif session.direction == "outgoing" then |
367 session.notopen = nil; | 366 session.notopen = nil; |
368 if not attr.id then | 367 if not attr.id then |