changeset 15887:48c1c58948f5

proxying cleanup: Send TTL=1 (instead of TTL=0) as "no more proxying".
author Timo Sirainen <tss@iki.fi>
date Fri, 22 Feb 2013 12:42:26 +0200
parents 8740056e9b2f
children c43fcfa2c4b4
files src/imap-login/imap-proxy.c src/lib-lda/lmtp-client.c src/lib-lda/lmtp-client.h src/lmtp/commands.c src/lmtp/lmtp-proxy.c src/login-common/login-proxy.c src/pop3-login/pop3-proxy.c
diffstat 7 files changed, 11 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/imap-login/imap-proxy.c	Fri Feb 22 10:32:05 2013 +0200
+++ b/src/imap-login/imap-proxy.c	Fri Feb 22 12:42:26 2013 +0200
@@ -29,7 +29,7 @@
 
 static void proxy_write_id(struct imap_client *client, string_t *str)
 {
-	i_assert(client->common.proxy_ttl > 0);
+	i_assert(client->common.proxy_ttl > 1);
 
 	str_printfa(str, "I ID ("
 		    "\"x-session-id\" \"%s\" "
--- a/src/lib-lda/lmtp-client.c	Fri Feb 22 10:32:05 2013 +0200
+++ b/src/lib-lda/lmtp-client.c	Fri Feb 22 12:42:26 2013 +0200
@@ -97,7 +97,7 @@
 		p_strdup(pool, set->dns_client_socket_path);
 	client->set.source_ip = set->source_ip;
 	client->set.source_port = set->source_port;
-	client->set.proxy_ttl_plus_1 = set->proxy_ttl_plus_1;
+	client->set.proxy_ttl = set->proxy_ttl;
 	client->set.proxy_timeout_secs = set->proxy_timeout_secs;
 	client->finish_callback = finish_callback;
 	client->finish_context = context;
@@ -433,9 +433,9 @@
 	if (client->set.source_port != 0 &&
 	    str_array_icase_find(client->xclient_args, "PORT"))
 		str_printfa(str, " PORT=%u", client->set.source_port);
-	if (client->set.proxy_ttl_plus_1 != 0 &&
+	if (client->set.proxy_ttl != 0 &&
 	    str_array_icase_find(client->xclient_args, "TTL"))
-		str_printfa(str, " TTL=%u", client->set.proxy_ttl_plus_1-1);
+		str_printfa(str, " TTL=%u", client->set.proxy_ttl);
 	if (client->set.proxy_timeout_secs != 0 &&
 	    str_array_icase_find(client->xclient_args, "TIMEOUT"))
 		str_printfa(str, " TIMEOUT=%u", client->set.proxy_timeout_secs);
--- a/src/lib-lda/lmtp-client.h	Fri Feb 22 10:32:05 2013 +0200
+++ b/src/lib-lda/lmtp-client.h	Fri Feb 22 12:42:26 2013 +0200
@@ -21,8 +21,8 @@
 	   send the these as ADDR/PORT/TTL/TIMEOUT */
 	struct ip_addr source_ip;
 	unsigned int source_port;
-	/* send TTL as this -1, so the default 0 means "don't send it" */
-	unsigned int proxy_ttl_plus_1;
+	/* send TTL as this (default 0 means "don't send it") */
+	unsigned int proxy_ttl;
 	/* remote is notified that the connection is going to be closed after
 	   this many seconds, so it should try to keep lock waits and such
 	   lower than this. */
--- a/src/lmtp/commands.c	Fri Feb 22 10:32:05 2013 +0200
+++ b/src/lmtp/commands.c	Fri Feb 22 12:42:26 2013 +0200
@@ -297,7 +297,7 @@
 		return TRUE;
 	}
 
-	if (client->proxy_ttl == 0) {
+	if (client->proxy_ttl <= 1) {
 		i_error("Proxying to <%s> appears to be looping (TTL=0)",
 			username);
 		client_send_line(client, "554 5.4.6 <%s> "
--- a/src/lmtp/lmtp-proxy.c	Fri Feb 22 10:32:05 2013 +0200
+++ b/src/lmtp/lmtp-proxy.c	Fri Feb 22 12:42:26 2013 +0200
@@ -61,6 +61,7 @@
 	struct lmtp_proxy *proxy;
 	pool_t pool;
 
+	i_assert(set->proxy_ttl > 0);
 	o_stream_ref(client_output);
 
 	pool = pool_alloconly_create("lmtp proxy", 1024);
@@ -136,7 +137,7 @@
 	client_set.dns_client_socket_path = proxy->set.dns_client_socket_path;
 	client_set.source_ip = proxy->set.source_ip;
 	client_set.source_port = proxy->set.source_port;
-	client_set.proxy_ttl_plus_1 = proxy->set.proxy_ttl+1;
+	client_set.proxy_ttl = proxy->set.proxy_ttl;
 	client_set.proxy_timeout_secs = set->timeout_msecs/1000;
 
 	conn = p_new(proxy->pool, struct lmtp_proxy_connection, 1);
--- a/src/login-common/login-proxy.c	Fri Feb 22 10:32:05 2013 +0200
+++ b/src/login-common/login-proxy.c	Fri Feb 22 12:42:26 2013 +0200
@@ -299,7 +299,7 @@
 		return -1;
 	}
 
-	if (client->proxy_ttl == 0) {
+	if (client->proxy_ttl <= 1) {
 		i_error("proxy(%s): TTL reached zero - "
 			"proxies appear to be looping?", client->virtual_user);
 		return -1;
--- a/src/pop3-login/pop3-proxy.c	Fri Feb 22 10:32:05 2013 +0200
+++ b/src/pop3-login/pop3-proxy.c	Fri Feb 22 12:42:26 2013 +0200
@@ -37,7 +37,7 @@
 {
 	string_t *str;
 
-	i_assert(client->common.proxy_ttl > 0);
+	i_assert(client->common.proxy_ttl > 1);
 	if (client->proxy_xclient) {
 		/* remote supports XCLIENT, send it */
 		o_stream_nsend_str(output, t_strdup_printf(