PIPE_CONNECT: avoid using when the transport helo_data uses $sending_ip_address
[exim.git] / src / src / transports / smtp.c
index 3ed2166ce591a1544b5f35f59f741473964e90ee..5c7b440c170e5163e763d760e91451223babe036 100644 (file)
@@ -2106,17 +2106,29 @@ if (!continue_hostname)
   sx->avoid_option = sx->peer_offered = smtp_peer_options = 0;
 
 #ifdef EXPERIMENTAL_PIPE_CONNECT
-  if (verify_check_given_host(CUSS &ob->hosts_pipe_connect, sx->conn_args.host) == OK)
-    {
-    sx->early_pipe_ok = TRUE;
-    if (  read_ehlo_cache_entry(sx)
-       && sx->ehlo_resp.cleartext_features & OPTION_EARLY_PIPE)
+  if (  verify_check_given_host(CUSS &ob->hosts_pipe_connect,
+                                           sx->conn_args.host) == OK)
+
+    /* We don't find out the local ip address until the connect, so if
+    the helo string might use it avoid doing early-pipelining. */
+
+    if (  !sx->helo_data
+       || !Ustrstr(sx->helo_data, "$sending_ip_address")
+       || Ustrstr(sx->helo_data, "def:sending_ip_address")
+       )
       {
-      DEBUG(D_transport) debug_printf("Using cached cleartext PIPE_CONNECT\n");
-      sx->early_pipe_active = TRUE;
-      sx->peer_offered = sx->ehlo_resp.cleartext_features;
+      sx->early_pipe_ok = TRUE;
+      if (  read_ehlo_cache_entry(sx)
+        && sx->ehlo_resp.cleartext_features & OPTION_EARLY_PIPE)
+       {
+       DEBUG(D_transport)
+         debug_printf("Using cached cleartext PIPE_CONNECT\n");
+       sx->early_pipe_active = TRUE;
+       sx->peer_offered = sx->ehlo_resp.cleartext_features;
+       }
       }
-    }
+    else DEBUG(D_transport)
+      debug_printf("helo needs $sending_ip_address\n");
 
   if (sx->early_pipe_active)
     sx->outblock.conn_args = &sx->conn_args;