diff options
author | Kim Alvefur <zash@zash.se> | 2014-05-22 22:48:06 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2014-05-22 22:48:06 +0200 |
commit | b4934b66b964b38ff81f3d51cfc18ecb982af821 (patch) | |
tree | 08ef082e5bcc5d9f52132ebc4800e0c97a739a91 /plugins/mod_s2s/mod_s2s.lua | |
parent | 6eef30829cec33b4def141a013b9deb400bd84cb (diff) | |
download | prosody-b4934b66b964b38ff81f3d51cfc18ecb982af821.tar.gz prosody-b4934b66b964b38ff81f3d51cfc18ecb982af821.zip |
mod_s2s: Move filter initialization to common place
Diffstat (limited to 'plugins/mod_s2s/mod_s2s.lua')
-rw-r--r-- | plugins/mod_s2s/mod_s2s.lua | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/plugins/mod_s2s/mod_s2s.lua b/plugins/mod_s2s/mod_s2s.lua index d35fc489..b256374a 100644 --- a/plugins/mod_s2s/mod_s2s.lua +++ b/plugins/mod_s2s/mod_s2s.lua @@ -541,7 +541,23 @@ local function initialize_session(session) session.stream_attrs = session_stream_attrs; - local filter = session.filter; + local filter = initialize_filters(session); + local conn = session.conn; + local w = conn.write; + + function session.sends2s(t) + log("debug", "sending: %s", t.top_tag and t:top_tag() or t:match("^[^>]*>?")); + if t.name then + t = filter("stanzas/out", t); + end + if t then + t = filter("bytes/out", tostring(t)); + if t then + return w(conn, t); + end + end + end + function session.data(data) data = filter("bytes/in", data); if data then @@ -580,22 +596,6 @@ function listener.onconnect(conn) session = s2s_new_incoming(conn); sessions[conn] = session; session.log("debug", "Incoming s2s connection"); - - local filter = initialize_filters(session); - local w = conn.write; - session.sends2s = function (t) - log("debug", "sending: %s", t.top_tag and t:top_tag() or t:match("^([^>]*>?)")); - if t.name then - t = filter("stanzas/out", t); - end - if t then - t = filter("bytes/out", tostring(t)); - if t then - return w(conn, t); - end - end - end - initialize_session(session); else -- Outgoing session connected session:open_stream(session.from_host, session.to_host); |