aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_s2s.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2022-01-21 17:59:19 +0100
committerKim Alvefur <zash@zash.se>2022-01-21 17:59:19 +0100
commit268dfa38c09c78b0bdab2cb1e3590b1ffa3ad86e (patch)
tree4b547f5bb0b192380a8efcbbd59cb5633e272566 /plugins/mod_s2s.lua
parent9f1af0be2e0f546ef10601df189988c069107963 (diff)
downloadprosody-268dfa38c09c78b0bdab2cb1e3590b1ffa3ad86e.tar.gz
prosody-268dfa38c09c78b0bdab2cb1e3590b1ffa3ad86e.zip
mod_s2s: Enable outgoing Direct TLS connections
Makes it faster by cutting out the roundtrips involved in <starttls/>, at the cost of making an additional SRV lookup. Since we already ignore a missing <starttls/> offer and try anyway there is not much difference in security. The fact that XMPP is used and the hostnames involved might still be visible until the future Encrypted ClientHello extension allows hiding those too.
Diffstat (limited to 'plugins/mod_s2s.lua')
-rw-r--r--plugins/mod_s2s.lua11
1 files changed, 9 insertions, 2 deletions
diff --git a/plugins/mod_s2s.lua b/plugins/mod_s2s.lua
index 7b915194..66b4c56b 100644
--- a/plugins/mod_s2s.lua
+++ b/plugins/mod_s2s.lua
@@ -29,6 +29,7 @@ local uuid_gen = require "util.uuid".generate;
local runner = require "util.async".runner;
local connect = require "net.connect".connect;
local service = require "net.resolvers.service";
+local resolver_chain = require "net.resolvers.chain";
local errors = require "util.error";
local set = require "util.set";
@@ -217,8 +218,14 @@ function route_to_new_session(event)
log("debug", "stanza [%s] queued until connection complete", stanza.name);
-- FIXME Cleaner solution to passing extra data from resolvers to net.server
-- This mt-clone allows resolvers to add extra data, currently used for DANE TLSA records
- local extra = setmetatable({}, s2s_service_options_mt);
- connect(service.new(to_host, "xmpp-server", "tcp", extra), listener, nil, { session = host_session });
+ local xmpp_extra = setmetatable({}, s2s_service_options_mt);
+ local sslctx = require"core.certmanager".create_context(from_host, "client"); -- TODO this should live in mod_tls ?
+ local xmpps_extra = setmetatable({ default_port = false; servername = to_host; sslctx = sslctx }, s2s_service_options_mt);
+ local direct_and_normal = resolver_chain.new({
+ service.new(to_host, "xmpps-server", "tcp", xmpps_extra);
+ service.new(to_host, "xmpp-server", "tcp", xmpp_extra);
+ });
+ connect(direct_and_normal, listener, nil, { session = host_session });
m_initiated_connections:with_labels(from_host):add(1)
return true;
end