<commit_before>-- Prosody IM
-- Copyright (C) 2008-2010 <NAME>
-- Copyright (C) 2008-2010 <NAME>
-- 
-- This project is MIT/X11 licensed. Please see the
-- COPYING file in the source package for more information.
--

--- Module containing all the logic for connecting to a remote server

local wrapclient = require "net.server".wrapclient;
local initialize_filters = require "util.filters".initialize;
local idna_to_ascii = require "util.encodings".idna.to_ascii;
local add_task = require "util.timer".add_task;
local new_ip = require "util.ip".new_ip;
local rfc3484_dest = require "util.rfc3484".destination;
local socket = require "socket";
local t_insert, t_sort = table.insert, table.sort;
local st = require "util.stanza";

local s2s_destroy_session = require "core.s2smanager".destroy_session;
local s2s_new_outgoing = require "core.s2smanager".new_outgoing;

local s2sout = {};

local s2s_listener;

function s2sout.set_listener(listener)
	s2s_listener = listener;
end

local function compare_srv_priorities(a,b)
	return a.priority < b.priority or (a.priority == b.priority and a.weight > b.weight);
end

local function session_open_stream(session, from, to)
	session.sends2s(st.stanza("stream:stream", {
		xmlns='jabber:server', ["xmlns:db"]='jabber:server:dialback',
		["xmlns:stream"]='http://etherx.jabber.org/streams',
		from=from, to=to, version='1.0', ["xml:lang"]='en'}):top_tag());
end

function s2sout.initiate_connection(host_session)
	initialize_filters(host_session);
	session.open_stream = session_open_stream;
	
	-- Kick the connection attempting machine into life
	if not s2sout.attempt_connection(host_session) then
		-- Intentionally not returning here, the
		-- session is needed, connected or not
		s2s_destroy_session(host_session);<commit_msg>s2sout.lib: Add locals for source interfaces<commit_after>-- Prosody IM
-- Copyright (C) 2008-2010 <NAME>
-- Copyright (C) 2008-2010 <NAME>
-- 
-- This project is MIT/X11 licensed. Please see the
-- COPYING file in the source package for more information.
--

--- Module containing all the logic for connecting to a remote server

local wrapclient = require "net.server".wrapclient;
local initialize_filters = require "util.filters".initialize;
local idna_to_ascii = require "util.encodings".idna.to_ascii;
local add_task = require "util.timer".add_task;
local new_ip = require "util.ip".new_ip;
local rfc3484_dest = require "util.rfc3484".destination;
local socket = require "socket";
local t_insert, t_sort = table.insert, table.sort;
local st = require "util.stanza";

local s2s_destroy_session = require "core.s2smanager".destroy_session;
local s2s_new_outgoing = require "core.s2smanager".new_outgoing;

local s2sout = {};

local s2s_listener;

local cfg_sources = config.get("*", "core", "s2s_interfaces") or {"*"};
local sources

function s2sout.set_listener(listener)
	s2s_listener = listener;
end

local function compare_srv_priorities(a,b)
	return a.priority < b.priority or (a.priority == b.priority and a.weight > b.weight);
end

local function session_open_stream(session, from, to)
	session.sends2s(st.stanza("stream:stream", {
		xmlns='jabber:server', ["xmlns:db"]='jabber:server:dialback',
		["xmlns:stream"]='http://etherx.jabber.org/streams',
		from=from, to=to, version='1.0', ["xml:lang"]='en'}):top_tag());
end

function s2sout.initiate_connection(host_session)
	initialize_filters(host_session);
	session.open_stream = session_open_stream;
	
	-- Kick the connection attempting machine into life
	if not s2sout.attempt_connection(host_session) then
		-- Intentionally not returning here, the
		-- session is needed, connected or not
		s2s_destroy_session(host_session);
{'fraction_non_alphanumeric': 0.12261059530311305, 'fraction_numerical': 0.02239213544511196, 'mean_word_length': 5.483185840707964, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6026256', 'n_tokens_mistral': 1278, 'n_tokens_neox': 1202, 'n_words': 308}