Mercurial > prosody-hg
comparison plugins/mod_s2s/mod_s2s.lua @ 6063:e626ee2fe106
mod_c2s, mod_s2s, mod_component, util.xmppstream: Move all session:open_stream() functions to util.xmppstream
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Thu, 10 Apr 2014 13:13:07 +0200 |
| parents | d21ea6001bba |
| children | 446148cad35e |
comparison
equal
deleted
inserted
replaced
| 6062:6cc6b4d407df | 6063:e626ee2fe106 |
|---|---|
| 508 conn:close(); -- Close immediately, as this is an outgoing connection or is not authed | 508 conn:close(); -- Close immediately, as this is an outgoing connection or is not authed |
| 509 end | 509 end |
| 510 end | 510 end |
| 511 end | 511 end |
| 512 | 512 |
| 513 function session_open_stream(session, from, to) | |
| 514 local attr = { | |
| 515 ["xmlns:stream"] = 'http://etherx.jabber.org/streams', | |
| 516 xmlns = 'jabber:server', | |
| 517 version = session.version and (session.version > 0 and "1.0" or nil), | |
| 518 ["xml:lang"] = 'en', | |
| 519 id = session.streamid, | |
| 520 from = from, to = to, | |
| 521 } | |
| 522 if not from or (hosts[from] and hosts[from].modules.dialback) then | |
| 523 attr["xmlns:db"] = 'jabber:server:dialback'; | |
| 524 end | |
| 525 | |
| 526 session.sends2s("<?xml version='1.0'?>"); | |
| 527 session.sends2s(st.stanza("stream:stream", attr):top_tag()); | |
| 528 return true; | |
| 529 end | |
| 530 | |
| 531 -- Session initialization logic shared by incoming and outgoing | 513 -- Session initialization logic shared by incoming and outgoing |
| 532 local function initialize_session(session) | 514 local function initialize_session(session) |
| 533 local stream = new_xmpp_stream(session, stream_callbacks); | 515 local stream = new_xmpp_stream(session, stream_callbacks); |
| 534 session.stream = stream; | 516 session.stream = stream; |
| 535 | 517 |
| 537 | 519 |
| 538 function session.reset_stream() | 520 function session.reset_stream() |
| 539 session.notopen = true; | 521 session.notopen = true; |
| 540 session.stream:reset(); | 522 session.stream:reset(); |
| 541 end | 523 end |
| 542 | |
| 543 session.open_stream = session_open_stream; | |
| 544 | 524 |
| 545 local filter = session.filter; | 525 local filter = session.filter; |
| 546 function session.data(data) | 526 function session.data(data) |
| 547 data = filter("bytes/in", data); | 527 data = filter("bytes/in", data); |
| 548 if data then | 528 if data then |
