]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
submission: Split the EHLO command into a generic part and a part related to relaying...
authorStephan Bosch <stephan.bosch@dovecot.fi>
Sat, 1 Sep 2018 11:30:34 +0000 (13:30 +0200)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Tue, 9 Oct 2018 06:41:17 +0000 (06:41 +0000)
src/submission/cmd-helo.c
src/submission/submission-commands.h

index 2e4673d1a56cfbdf2893f48c8dec255ce25b68b7..46d00e51c96e7f9dc75246e5e53ccd301519c5f0 100644 (file)
@@ -87,10 +87,9 @@ cmd_helo_start(struct smtp_server_cmd_ctx *cmd ATTR_UNUSED,
                cmd_helo_update_xclient(client, helo->data);
 }
 
-int cmd_helo(void *conn_ctx, struct smtp_server_cmd_ctx *cmd,
-            struct smtp_server_cmd_helo *data)
+int cmd_helo_relay(struct client *client, struct smtp_server_cmd_ctx *cmd,
+                  struct smtp_server_cmd_helo *data)
 {
-       struct client *client = conn_ctx;
        struct cmd_helo_context *helo;
 
        helo = p_new(cmd->pool, struct cmd_helo_context, 1);
@@ -98,19 +97,27 @@ int cmd_helo(void *conn_ctx, struct smtp_server_cmd_ctx *cmd,
        helo->cmd = cmd;
        helo->data = data;
 
-       if (!data->first || smtp_server_connection_get_state(client->conn)
-               >= SMTP_SERVER_STATE_READY) {
-               /* this is not the first HELO/EHLO; just proxy a RSET command */
-               smtp_server_command_add_hook(
-                       cmd->cmd, SMTP_SERVER_COMMAND_HOOK_NEXT,
-                       cmd_helo_start, helo);
-               helo->cmd_proxied = smtp_client_command_rset_submit
-                       (client->proxy_conn, 0, cmd_helo_proxy_cb, helo);
-               return 0;
-       }
+       /* this is not the first HELO/EHLO; just proxy a RSET command */
+       smtp_server_command_add_hook(
+               cmd->cmd, SMTP_SERVER_COMMAND_HOOK_NEXT,
+               cmd_helo_start, helo);
+       helo->cmd_proxied = smtp_client_command_rset_submit
+               (client->proxy_conn, 0, cmd_helo_proxy_cb, helo);
+       return 0;
+}
+
+int cmd_helo(void *conn_ctx, struct smtp_server_cmd_ctx *cmd,
+            struct smtp_server_cmd_helo *data)
+{
+       struct client *client = conn_ctx;
+
+       if (!data->first ||
+           smtp_server_connection_get_state(client->conn)
+               >= SMTP_SERVER_STATE_READY)
+               return cmd_helo_relay(client, cmd, data);
 
        /* respond right away */
-       cmd_helo_reply(cmd, helo);
+       submission_helo_reply_submit(cmd, data);
        return 1;
 }
 
index 79afe1cce6b433562333bacf49734d6c435519fd..6d672e0e2f90cbad3a1b5803719471fce6fc018f 100644 (file)
@@ -4,6 +4,9 @@
 bool client_command_handle_proxy_reply(struct client *client,
        const struct smtp_reply *reply, struct smtp_reply *reply_r);
 
+int cmd_helo_relay(struct client *client, struct smtp_server_cmd_ctx *cmd,
+                  struct smtp_server_cmd_helo *data);
+
 void submission_helo_reply_submit(struct smtp_server_cmd_ctx *cmd,
                                  struct smtp_server_cmd_helo *data);
 int cmd_helo(void *conn_ctx, struct smtp_server_cmd_ctx *cmd,