From db9c9117116b1a1bc7889d6f79c35e98b9220d1a Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Tue, 18 Jun 2013 12:11:40 +0100 Subject: mod_s2s/s2sout.lib: Only attempt to create an IPv6 socket if LuaSocket supports IPv6 --- plugins/mod_s2s/s2sout.lib.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'plugins/mod_s2s/s2sout.lib.lua') diff --git a/plugins/mod_s2s/s2sout.lib.lua b/plugins/mod_s2s/s2sout.lib.lua index cb2f8be4..9e26dbee 100644 --- a/plugins/mod_s2s/s2sout.lib.lua +++ b/plugins/mod_s2s/s2sout.lib.lua @@ -276,10 +276,13 @@ function s2sout.make_connect(host_session, connect_host, connect_port) host_session.secure = nil; local conn, handler; - if connect_host.proto == "IPv4" then + local proto = connect_host.proto; + if proto == "IPv4" then conn, handler = socket.tcp(); - else + elseif proto == "IPv6" and socket.tcp6 then conn, handler = socket.tcp6(); + else + handler = "Unsupported protocol: "..tostring(proto); end if not conn then -- cgit v1.2.3 From 207182610852efd14fc211f0c6c1e38d36439dde Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Tue, 18 Jun 2013 12:12:12 +0100 Subject: mod_s2s/s2sout.lib: Use new util.net.local_addresses() to fetch local interface addresses --- plugins/mod_s2s/s2sout.lib.lua | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'plugins/mod_s2s/s2sout.lib.lua') diff --git a/plugins/mod_s2s/s2sout.lib.lua b/plugins/mod_s2s/s2sout.lib.lua index 9e26dbee..6d6d2062 100644 --- a/plugins/mod_s2s/s2sout.lib.lua +++ b/plugins/mod_s2s/s2sout.lib.lua @@ -19,6 +19,7 @@ local adns = require "net.adns"; 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 @@ module:hook_global("service-added", function (event) 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"); -- cgit v1.2.3 From fac4a3ce24652a0be10b9491f97533ac76522379 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Tue, 18 Jun 2013 12:12:49 +0100 Subject: mod_s2s/s2sout.lib: Remove reference to undefined global --- plugins/mod_s2s/s2sout.lib.lua | 1 - 1 file changed, 1 deletion(-) (limited to 'plugins/mod_s2s/s2sout.lib.lua') diff --git a/plugins/mod_s2s/s2sout.lib.lua b/plugins/mod_s2s/s2sout.lib.lua index 6d6d2062..cc682280 100644 --- a/plugins/mod_s2s/s2sout.lib.lua +++ b/plugins/mod_s2s/s2sout.lib.lua @@ -48,7 +48,6 @@ end function s2sout.initiate_connection(host_session) initialize_filters(host_session); host_session.version = 1; - host_session.open_stream = session_open_stream; -- Kick the connection attempting machine into life if not s2sout.attempt_connection(host_session) then -- cgit v1.2.3 From 67f89befd7e31e13fbdc2b770c29fa62b7573f1a Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Tue, 18 Jun 2013 12:14:46 +0100 Subject: mod_s2s/s2sout.lib: Remove unused variables and imports --- plugins/mod_s2s/s2sout.lib.lua | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'plugins/mod_s2s/s2sout.lib.lua') diff --git a/plugins/mod_s2s/s2sout.lib.lua b/plugins/mod_s2s/s2sout.lib.lua index cc682280..575d37ac 100644 --- a/plugins/mod_s2s/s2sout.lib.lua +++ b/plugins/mod_s2s/s2sout.lib.lua @@ -18,7 +18,6 @@ local socket = require "socket"; local adns = require "net.adns"; 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; @@ -74,7 +73,7 @@ function s2sout.initiate_connection(host_session) end function s2sout.attempt_connection(host_session, err) - local from_host, to_host = host_session.from_host, host_session.to_host; + local to_host = host_session.to_host; local connect_host, connect_port = to_host and idna_to_ascii(to_host), 5269; if not connect_host then @@ -267,10 +266,7 @@ end function s2sout.make_connect(host_session, connect_host, connect_port) (host_session.log or log)("info", "Beginning new connection attempt to %s ([%s]:%d)", host_session.to_host, connect_host.addr, connect_port); - -- Ok, we're going to try to connect - - local from_host, to_host = host_session.from_host, host_session.to_host; - + -- Reset secure flag in case this is another -- connection attempt after a failed STARTTLS host_session.secure = nil; -- cgit v1.2.3