Changeset

4443:7456ddcc0b14

s2smanager: Store port specified by SRV records
author Florian Zeitz <florob@babelmonkeys.de>
date Wed, 07 Dec 2011 23:37:56 +0100
parents 4442:bc0a68cae236
children 4444:498eaeff6a05
files core/s2smanager.lua
diffstat 1 files changed, 11 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/core/s2smanager.lua	Wed Dec 07 05:54:17 2011 +0000
+++ b/core/s2smanager.lua	Wed Dec 07 23:37:56 2011 +0100
@@ -295,11 +295,11 @@
 	return try_connect(host_session, connect_host, connect_port);
 end
 
-function try_next_ip(host_session, connect_port)
+function try_next_ip(host_session)
 	host_session.connecting = nil;
 	host_session.ip_choice = host_session.ip_choice + 1;
 	local ip = host_session.ip_hosts[host_session.ip_choice];
-	local ok, err= make_connect(host_session, ip, connect_port);
+	local ok, err= make_connect(host_session, ip.ip, ip.port);
 	if not ok then
 		if not attempt_connection(host_session, err or "closed") then
 			err = err and (": "..err) or "";
@@ -354,8 +354,11 @@
 			if has_other then
 				if #IPs > 0 then
 					rfc3484_dest(host_session.ip_hosts, sources);
+					for i = 1, #IPs do
+						IPs[i] = {ip = IPs[i], port = connect_port};
+					end
 					host_session.ip_choice = 0;
-					try_next_ip(host_session, connect_port);
+					try_next_ip(host_session);
 				else
 					log("debug", "DNS lookup failed to get a response for %s", connect_host);
 					host_session.ip_hosts = nil;
@@ -383,8 +386,11 @@
 			if has_other then
 				if #IPs > 0 then
 					rfc3484_dest(host_session.ip_hosts, sources);
+					for i = 1, #IPs do
+						IPs[i] = {ip = IPs[i], port = connect_port};
+					end
 					host_session.ip_choice = 0;
-					try_next_ip(host_session, connect_port);
+					try_next_ip(host_session);
 				else
 					log("debug", "DNS lookup failed to get a response for %s", connect_host);
 					host_session.ip_hosts = nil;
@@ -401,7 +407,7 @@
 
 		return true;
 	elseif host_session.ip_hosts and #host_session.ip_hosts > host_session.ip_choice then -- Not our first attempt, and we also have IPs left to try
-		try_next_ip(host_session, connect_port);
+		try_next_ip(host_session);
 	else
 		host_session.ip_hosts = nil;
 		if not attempt_connection(host_session, "out of IP addresses") then -- Retry if we can