Changeset

5701:746b263e09cf

mod_s2s/s2sout.lib: Use new util.net.local_addresses() to fetch local interface addresses
author Matthew Wild <mwild1@gmail.com>
date Tue, 18 Jun 2013 12:12:12 +0100
parents 5700:94081567ea9e
children 5702:a56691e3c7d1
files plugins/mod_s2s/s2sout.lib.lua
diffstat 1 files changed, 5 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_s2s/s2sout.lib.lua	Tue Jun 18 12:11:40 2013 +0100
+++ b/plugins/mod_s2s/s2sout.lib.lua	Tue Jun 18 12:12:12 2013 +0100
@@ -19,6 +19,7 @@
 local dns = require "net.dns";
 local t_insert, t_sort, ipairs = table.insert, table.sort, ipairs;
 local st = require "util.stanza";
+local local_addresses = require "util.net".local_addresses;
 
 local s2s_destroy_session = require "core.s2smanager".destroy_session;
 
@@ -333,20 +334,12 @@
 	end
 	for source, _ in pairs(s2s_sources) do
 		if source == "*" or source == "0.0.0.0" then
-			if not socket.local_addresses then
-				sources[#sources + 1] = new_ip("0.0.0.0", "IPv4");
-			else
-				for _, addr in ipairs(socket.local_addresses("ipv4", true)) do
-					sources[#sources + 1] = new_ip(addr, "IPv4");
-				end
+			for _, addr in ipairs(local_addresses("ipv4", true)) do
+				sources[#sources + 1] = new_ip(addr, "IPv4");
 			end
 		elseif source == "::" then
-			if not socket.local_addresses then
-				sources[#sources + 1] = new_ip("::", "IPv6");
-			else
-				for _, addr in ipairs(socket.local_addresses("ipv6", true)) do
-					sources[#sources + 1] = new_ip(addr, "IPv6");
-				end
+			for _, addr in ipairs(local_addresses("ipv6", true)) do
+				sources[#sources + 1] = new_ip(addr, "IPv6");
 			end
 		else
 			sources[#sources + 1] = new_ip(source, (source:find(":") and "IPv6") or "IPv4");