Diff

plugins/s2s/s2sout.lib.lua @ 4573:09255a10fdfa

Merge Zash with Florob and Maranda
author Matthew Wild <mwild1@gmail.com>
date Fri, 24 Feb 2012 16:23:46 +0000
parent 4564:a11b4cbac3c5
parent 4570:9612abc89dd1
child 4599:f9f5230d7a9c
line wrap: on
line diff
--- a/plugins/s2s/s2sout.lib.lua	Thu Feb 23 23:12:24 2012 +0100
+++ b/plugins/s2s/s2sout.lib.lua	Fri Feb 24 16:23:46 2012 +0000
@@ -15,18 +15,18 @@
 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 t_insert, t_sort, ipairs = table.insert, table.sort, ipairs;
 local st = require "util.stanza";
 
+local s2s_new_outgoing = require "core.s2smanager".new_outgoing;
 local s2s_destroy_session = require "core.s2smanager".destroy_session;
-local s2s_new_outgoing = require "core.s2smanager".new_outgoing;
+
+local cfg_sources = config.get("*", "core", "s2s_interfaces") or socket.local_addresses and socket.local_addresses() or { "*" };
 
 local s2sout = {};
 
 local s2s_listener;
 
-local cfg_sources = config.get("*", "core", "s2s_interfaces") or {"*"};
-local sources
 
 function s2sout.set_listener(listener)
 	s2s_listener = listener;
@@ -156,6 +156,7 @@
 end
 
 function s2sout.try_connect(host_session, connect_host, connect_port, err)
+	local sources;
 	host_session.connecting = true;
 
 	if not err then
@@ -165,7 +166,7 @@
 		local has_other = false;
 
 		if not sources then
-			sources =  {};
+			sources = {};
 			for i, source in ipairs(cfg_sources) do
 				if source == "*" then
 					sources[i] = new_ip("0.0.0.0", "IPv4");