Software /
code /
prosody
Comparison
plugins/mod_s2s/mod_s2s.lua @ 6146:ac4f8770d9aa
mod_s2s: Follow XMPP Core on when a stream is to be considered ready
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 22 Apr 2014 21:56:06 +0200 |
parent | 6085:2f911644f527 |
child | 6255:6167f8bc5a6b |
comparison
equal
deleted
inserted
replaced
6089:d774cb85664b | 6146:ac4f8770d9aa |
---|---|
148 end | 148 end |
149 module:hook("route/remote", route_to_existing_session, -1); | 149 module:hook("route/remote", route_to_existing_session, -1); |
150 module:hook("route/remote", route_to_new_session, -10); | 150 module:hook("route/remote", route_to_new_session, -10); |
151 module:hook("s2s-authenticated", make_authenticated, -1); | 151 module:hook("s2s-authenticated", make_authenticated, -1); |
152 module:hook("s2s-read-timeout", keepalive, -1); | 152 module:hook("s2s-read-timeout", keepalive, -1); |
153 module:hook_stanza("http://etherx.jabber.org/streams", "features", function (session, stanza) | |
154 if session.type == "s2sout" then | |
155 -- Stream is authenticated and we are seem to be done with feature negotiation, | |
156 -- so the stream is ready for stanzas. RFC 6120 Section 4.3 | |
157 mark_connected(session); | |
158 end | |
159 end, -1); | |
153 end | 160 end |
154 | 161 |
155 -- Stream is authorised, and ready for normal stanzas | 162 -- Stream is authorised, and ready for normal stanzas |
156 function mark_connected(session) | 163 function mark_connected(session) |
157 local sendq, send = session.sendq, session.sends2s; | 164 local sendq, send = session.sendq, session.sends2s; |
217 else | 224 else |
218 return false; | 225 return false; |
219 end | 226 end |
220 session.log("debug", "connection %s->%s is now authenticated for %s", session.from_host, session.to_host, host); | 227 session.log("debug", "connection %s->%s is now authenticated for %s", session.from_host, session.to_host, host); |
221 | 228 |
222 mark_connected(session); | 229 if (session.type == "s2sout" and session.external_auth ~= "succeeded") or session.type == "s2sin" then |
230 -- Stream either used dialback for authentication or is an incoming stream. | |
231 mark_connected(session); | |
232 end | |
223 | 233 |
224 return true; | 234 return true; |
225 end | 235 end |
226 | 236 |
227 --- Helper to check that a session peer's certificate is valid | 237 --- Helper to check that a session peer's certificate is valid |