plugins/mod_s2s.lua
changeset 11711 61759372be26
parent 11709 7132acfd287e
child 11744 b92f2abe0bda
equal deleted inserted replaced
11710:56feb0cf7052 11711:61759372be26
    89 	default_port = 5269;
    89 	default_port = 5269;
    90 	use_ipv4 = module:get_option_boolean("use_ipv4", true);
    90 	use_ipv4 = module:get_option_boolean("use_ipv4", true);
    91 	use_ipv6 = module:get_option_boolean("use_ipv6", true);
    91 	use_ipv6 = module:get_option_boolean("use_ipv6", true);
    92 	use_dane = module:get_option_boolean("use_dane", false);
    92 	use_dane = module:get_option_boolean("use_dane", false);
    93 };
    93 };
       
    94 local s2s_service_options_mt = { __index = s2s_service_options }
    94 
    95 
    95 module:hook("stats-update", function ()
    96 module:hook("stats-update", function ()
    96 	measure_connections_inbound:clear()
    97 	measure_connections_inbound:clear()
    97 	measure_connections_outbound:clear()
    98 	measure_connections_outbound:clear()
    98 	-- TODO: init all expected metrics once?
    99 	-- TODO: init all expected metrics once?
   212 
   213 
   213 	-- Store in buffer
   214 	-- Store in buffer
   214 	host_session.bounce_sendq = bounce_sendq;
   215 	host_session.bounce_sendq = bounce_sendq;
   215 	host_session.sendq = { {tostring(stanza), stanza.attr.type ~= "error" and stanza.attr.type ~= "result" and st.reply(stanza)} };
   216 	host_session.sendq = { {tostring(stanza), stanza.attr.type ~= "error" and stanza.attr.type ~= "result" and st.reply(stanza)} };
   216 	log("debug", "stanza [%s] queued until connection complete", stanza.name);
   217 	log("debug", "stanza [%s] queued until connection complete", stanza.name);
   217 	connect(service.new(to_host, "xmpp-server", "tcp", s2s_service_options), listener, nil, { session = host_session });
   218 	-- FIXME Cleaner solution to passing extra data from resolvers to net.server
       
   219 	-- This mt-clone allows resolvers to add extra data, currently used for DANE TLSA records
       
   220 	local extra = setmetatable({}, s2s_service_options_mt);
       
   221 	connect(service.new(to_host, "xmpp-server", "tcp", extra), listener, nil, { session = host_session });
   218 	m_initiated_connections:with_labels(from_host):add(1)
   222 	m_initiated_connections:with_labels(from_host):add(1)
   219 	return true;
   223 	return true;
   220 end
   224 end
   221 
   225 
   222 local function keepalive(event)
   226 local function keepalive(event)