Changeset

13110:d5f322dd424b 0.12

mod_s2s: Add event where resolver for s2sout can be tweaked Could be used to implement custom connection methods (c.f. mod_onions) without needing to duplicate the rest of route_to_new_session(). Adds a feature to enable detection since it can be difficult to detect support for an event otherwise.
author Kim Alvefur <zash@zash.se>
date Thu, 18 Aug 2022 03:26:32 +0200
parents 13091:214a679823e8
children 13111:8576f94ac90a 13121:332e95f75dbb
files core/features.lua plugins/mod_s2s.lua
diffstat 2 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/core/features.lua	Mon May 01 15:10:32 2023 +0200
+++ b/core/features.lua	Thu Aug 18 03:26:32 2022 +0200
@@ -4,5 +4,7 @@
 	available = set.new{
 		-- mod_bookmarks bundled
 		"mod_bookmarks";
+
+		"s2sout-pre-connect-event";
 	};
 };
--- a/plugins/mod_s2s.lua	Mon May 01 15:10:32 2023 +0200
+++ b/plugins/mod_s2s.lua	Thu Aug 18 03:26:32 2022 +0200
@@ -230,6 +230,10 @@
 			resolver;
 		});
 	end
+
+	local pre_event = { session = host_session; resolver = resolver };
+	module:context(from_host):fire_event("s2sout-pre-connect", pre_event);
+	resolver = pre_event.resolver;
 	connect(resolver, listener, nil, { session = host_session });
 	m_initiated_connections:with_labels(from_host):add(1)
 	return true;