diff options
author | Matthew Wild <mwild1@gmail.com> | 2012-05-04 01:50:17 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2012-05-04 01:50:17 +0100 |
commit | 174997d348dce80b22b18c3265bc1abd9f87f688 (patch) | |
tree | 9eeee09196d28f3e675e7390b316e76ff54ddf62 /plugins/mod_s2s/mod_s2s.lua | |
parent | 5350e5a2607b8d200042545ccec2b3c5591f6cd5 (diff) | |
download | prosody-174997d348dce80b22b18c3265bc1abd9f87f688.tar.gz prosody-174997d348dce80b22b18c3265bc1abd9f87f688.zip |
mod_s2s: Become a shared module (yay)
Diffstat (limited to 'plugins/mod_s2s/mod_s2s.lua')
-rw-r--r-- | plugins/mod_s2s/mod_s2s.lua | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/plugins/mod_s2s/mod_s2s.lua b/plugins/mod_s2s/mod_s2s.lua index 649cd595..57564226 100644 --- a/plugins/mod_s2s/mod_s2s.lua +++ b/plugins/mod_s2s/mod_s2s.lua @@ -67,7 +67,8 @@ local function bounce_sendq(session, reason) session.sendq = nil; end -module:hook("route/remote", function (event) +-- Handles stanzas to existing s2s sessions +function route_to_existing_session(event) local from_host, to_host, stanza = event.from_host, event.to_host, event.stanza; if not hosts[from_host] then log("warn", "Attempt to send stanza from %s - a host we don't serve", from_host); @@ -101,9 +102,10 @@ module:hook("route/remote", function (event) return true; end end -end, 200); +end -module:hook("route/remote", function (event) +-- Create a new outgoing session for a stanza +function route_to_new_session(event) local from_host, to_host, stanza = event.from_host, event.to_host, event.stanza; log("debug", "opening a new outgoing connection for this stanza"); local host_session = s2s_new_outgoing(from_host, to_host); @@ -119,7 +121,15 @@ module:hook("route/remote", function (event) return false; end return true; -end, 100); +end + +function module.add_host(module) + if module:get_option_boolean("disallow_s2s", false) then + return nil, "This host has disallow_s2s set"; + end + module:hook("route/remote", route_to_existing_session, 200); + module:hook("route/remote", route_to_new_session, 100); +end --- Helper to check that a session peer's certificate is valid local function check_cert_status(session) |