Software /
code /
prosody
Comparison
plugins/mod_s2s.lua @ 12280:74f8739b967a
mod_s2s: Add new early s2s-connected events
Allows doing things based on connections rather than sessions, which may
have been created before or after.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 06 Feb 2022 14:31:27 +0100 |
parent | 12207:65e252940337 |
child | 12298:cb459f8fa740 |
comparison
equal
deleted
inserted
replaced
12279:f44eb0a6653a | 12280:74f8739b967a |
---|---|
818 local session = sessions[conn]; | 818 local session = sessions[conn]; |
819 if not session then -- New incoming connection | 819 if not session then -- New incoming connection |
820 session = s2s_new_incoming(conn); | 820 session = s2s_new_incoming(conn); |
821 sessions[conn] = session; | 821 sessions[conn] = session; |
822 session.log("debug", "Incoming s2s connection"); | 822 session.log("debug", "Incoming s2s connection"); |
823 module:fire_event("s2sin-connected", { session = session }) | |
823 initialize_session(session); | 824 initialize_session(session); |
824 m_accepted_tcp_connections:with_labels():add(1) | 825 m_accepted_tcp_connections:with_labels():add(1) |
825 else -- Outgoing session connected | 826 else -- Outgoing session connected |
827 module:fire_event("s2sout-connected", { session = session }) | |
826 session:open_stream(session.from_host, session.to_host); | 828 session:open_stream(session.from_host, session.to_host); |
827 end | 829 end |
830 module:fire_event("s2s-connected", { session = session }) | |
828 session.ip = conn:ip(); | 831 session.ip = conn:ip(); |
829 end | 832 end |
830 | 833 |
831 function listener.onincoming(conn, data) | 834 function listener.onincoming(conn, data) |
832 local session = sessions[conn]; | 835 local session = sessions[conn]; |