From 28e1592c0c34865d1583efc8d6aaf1740f22e439 Mon Sep 17 00:00:00 2001
From: Matthew Wild <mwild1@gmail.com>
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')

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