Changeset

11707:61759372be26

mod_s2s: Clone 'extra' data to let resolvers add more to it This way 'extra' is unique for each connect() instance, making it safer to mutate it, while inheriting the global settings. See 926d53af9a7a for some more context.
author Kim Alvefur <zash@zash.se>
date Sun, 18 Jul 2021 21:53:26 +0200
parents 11706:56feb0cf7052
children 11708:5ef729c355f3
files plugins/mod_s2s.lua
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_s2s.lua	Sun Jul 18 12:57:06 2021 +0200
+++ b/plugins/mod_s2s.lua	Sun Jul 18 21:53:26 2021 +0200
@@ -91,6 +91,7 @@
 	use_ipv6 = module:get_option_boolean("use_ipv6", true);
 	use_dane = module:get_option_boolean("use_dane", false);
 };
+local s2s_service_options_mt = { __index = s2s_service_options }
 
 module:hook("stats-update", function ()
 	measure_connections_inbound:clear()
@@ -214,7 +215,10 @@
 	host_session.bounce_sendq = bounce_sendq;
 	host_session.sendq = { {tostring(stanza), stanza.attr.type ~= "error" and stanza.attr.type ~= "result" and st.reply(stanza)} };
 	log("debug", "stanza [%s] queued until connection complete", stanza.name);
-	connect(service.new(to_host, "xmpp-server", "tcp", s2s_service_options), listener, nil, { session = host_session });
+	-- 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 });
 	m_initiated_connections:with_labels(from_host):add(1)
 	return true;
 end