]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
pop3-login: proxy - Add support for XCLIENT DESTIP and DESTPORT
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 2 Feb 2026 11:01:16 +0000 (13:01 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Fri, 6 Feb 2026 07:58:43 +0000 (07:58 +0000)
This is for preserving the server/local IP and port.

src/pop3-login/client.c
src/pop3-login/pop3-proxy.c

index dd9973987eacad970f3a7e052c61956fe76af8d0..46755e0c0a631f011880a6e0a7fa601e557ac256 100644 (file)
@@ -39,7 +39,7 @@ static bool cmd_quit(struct pop3_client *client)
 static bool cmd_xclient(struct pop3_client *client, const char *args)
 {
        const char *const *tmp, *value;
-       in_port_t remote_port;
+       in_port_t remote_port, local_port;
        bool args_ok = TRUE;
 
        if (!client->common.connection_trusted) {
@@ -56,6 +56,14 @@ static bool cmd_xclient(struct pop3_client *client, const char *args)
                                args_ok = FALSE;
                        else
                                client->common.remote_port = remote_port;
+               } else if (str_begins_icase(*tmp, "DESTADDR=", &value)) {
+                       if (net_addr2ip(value, &client->common.local_ip) < 0)
+                               args_ok = FALSE;
+               } else if (str_begins_icase(*tmp, "DESTPORT=", &value)) {
+                       if (net_str2port(value, &local_port) < 0)
+                               args_ok = FALSE;
+                       else
+                               client->common.local_port = local_port;
                } else if (str_begins_icase(*tmp, "SESSION=", &value)) {
                        if (strlen(value) <= LOGIN_MAX_SESSION_ID_LEN) {
                                client->common.session_id =
index 2389dc6f09afd929b925521a4efa47d11dc621ef..68f1c8b1d18c93f1983f58e98fa0cdf669fe186a 100644 (file)
@@ -44,10 +44,13 @@ static int proxy_send_login(struct pop3_client *client, struct ostream *output)
                         }
                }
 
-               str_printfa(str, "XCLIENT ADDR=%s PORT=%u SESSION=%s TTL=%u "
+               str_printfa(str, "XCLIENT ADDR=%s PORT=%u "
+                           "DESTADDR=%s DESTPORT=%u SESSION=%s TTL=%u "
                            "CLIENT-TRANSPORT=%s",
                            net_ip2addr(&client->common.ip),
                            client->common.remote_port,
+                           net_ip2addr(&client->common.local_ip),
+                           client->common.local_port,
                            client_get_session_id(&client->common),
                            client->common.proxy_ttl - 1,
                            client->common.end_client_tls_secured ?
@@ -60,6 +63,7 @@ static int proxy_send_login(struct pop3_client *client, struct ostream *output)
                        str_append(str, " FORWARD=");
                        base64_encode(str_data(fwd), str_len(fwd), str);
                }
+               e_info(client->common.event, "Send: %s", str_c(str));
                str_append(str, "\r\n");
                /* remote supports XCLIENT, send it */
                o_stream_nsend(output, str_data(str), str_len(str));