changeset 14160:9b79d71bff4e

pop3 proxy: Fixed handling XCLIENT reply.
author Timo Sirainen <tss@iki.fi>
date Sat, 25 Feb 2012 06:39:00 +0200
parents 98d696965c91
children f534ed81bce4
files src/pop3-login/client.h src/pop3-login/pop3-proxy.c
diffstat 2 files changed, 14 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/pop3-login/client.h	Sat Feb 25 05:42:05 2012 +0200
+++ b/src/pop3-login/client.h	Sat Feb 25 06:39:00 2012 +0200
@@ -8,6 +8,7 @@
 enum pop3_proxy_state {
 	POP3_PROXY_BANNER = 0,
 	POP3_PROXY_STARTTLS,
+	POP3_PROXY_XCLIENT,
 	POP3_PROXY_LOGIN1,
 	POP3_PROXY_LOGIN2
 };
--- a/src/pop3-login/pop3-proxy.c	Sat Feb 25 05:42:05 2012 +0200
+++ b/src/pop3-login/pop3-proxy.c	Sat Feb 25 06:39:00 2012 +0200
@@ -43,6 +43,9 @@
 			"XCLIENT ADDR=%s PORT=%u\r\n",
 			net_ip2addr(&client->common.ip),
 			client->common.remote_port));
+		client->common.proxy_state = POP3_PROXY_XCLIENT;
+	} else {
+		client->common.proxy_state = POP3_PROXY_LOGIN1;
 	}
 
 	str = t_str_new(128);
@@ -56,7 +59,6 @@
 		str_append(str, "AUTH PLAIN\r\n");
 	}
 	(void)o_stream_send(output, str_data(str), str_len(str));
-	client->common.proxy_state = POP3_PROXY_LOGIN1;
 }
 
 int pop3_proxy_parse_line(struct client *client, const char *line)
@@ -106,6 +108,16 @@
 		output = login_proxy_get_ostream(client->login_proxy);
 		proxy_send_login(pop3_client, output);
 		return 1;
+	case POP3_PROXY_XCLIENT:
+		if (strncmp(line, "+OK", 3) != 0) {
+			client_log_err(client, t_strdup_printf(
+				"proxy: Remote XCLIENT failed: %s",
+				str_sanitize(line, 160)));
+			client_proxy_failed(client, TRUE);
+			return -1;
+		}
+		client->proxy_state = POP3_PROXY_LOGIN1;
+		return 1;
 	case POP3_PROXY_LOGIN1:
 		str = t_str_new(128);
 		if (client->proxy_master_user == NULL) {