]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
submission: Move relay part of RCPT command to submission-backend-relay.c.
authorStephan Bosch <stephan.bosch@dovecot.fi>
Wed, 29 Aug 2018 20:45:00 +0000 (22:45 +0200)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Tue, 9 Oct 2018 06:41:17 +0000 (06:41 +0000)
src/submission/Makefile.am
src/submission/cmd-rcpt.c [deleted file]
src/submission/submission-backend-relay.c
src/submission/submission-backend-relay.h
src/submission/submission-commands.h

index 005da9786516ba3713dbb3be6698990ffcf66c8f..e397c18db977393cef071602f4709a96e289cfc3 100644 (file)
@@ -34,7 +34,6 @@ submission_DEPENDENCIES = \
        $(LIBDOVECOT_DEPS)
 
 cmds = \
-       cmd-rcpt.c \
        cmd-data.c \
        cmd-rset.c \
        cmd-noop.c \
diff --git a/src/submission/cmd-rcpt.c b/src/submission/cmd-rcpt.c
deleted file mode 100644 (file)
index fb1d679..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/* Copyright (c) 2013-2018 Dovecot authors, see the included COPYING file */
-
-#include "submission-common.h"
-#include "str.h"
-#include "array.h"
-#include "smtp-parser.h"
-#include "smtp-address.h"
-#include "smtp-syntax.h"
-#include "smtp-client.h"
-#include "smtp-client-connection.h"
-
-#include "submission-commands.h"
-
-/*
- * RCPT command
- */
-
-struct cmd_rcpt_context {
-       struct client *client;
-       struct smtp_server_cmd_ctx *cmd;
-       struct smtp_server_cmd_rcpt *data;
-
-       struct smtp_client_command *cmd_proxied;
-};
-
-static void
-cmd_rcpt_replied(struct smtp_server_cmd_ctx *cmd ATTR_UNUSED,
-                struct cmd_rcpt_context *rcpt_cmd)
-{
-       if (rcpt_cmd->cmd_proxied != NULL)
-               smtp_client_command_abort(&rcpt_cmd->cmd_proxied);
-}
-
-static void cmd_rcpt_proxy_cb(const struct smtp_reply *proxy_reply,
-                             struct cmd_rcpt_context *rcpt_cmd)
-{
-       struct smtp_server_cmd_ctx *cmd = rcpt_cmd->cmd;
-       struct client *client = rcpt_cmd->client;
-       struct smtp_reply reply;
-
-       /* finished proxying MAIL command to relay server */
-       i_assert(rcpt_cmd != NULL);
-       rcpt_cmd->cmd_proxied = NULL;
-
-       if (!client_command_handle_proxy_reply(client, proxy_reply, &reply))
-               return;
-
-       if ((proxy_reply->status / 100) == 2) {
-               /* the default 2.0.0 code won't do */
-               if (!smtp_reply_has_enhanced_code(proxy_reply))
-                       reply.enhanced_code = SMTP_REPLY_ENH_CODE(2, 1, 5);
-       }
-
-       /* forward reply */
-       smtp_server_reply_forward(cmd, &reply);
-}
-
-int cmd_rcpt_relay(struct client *client, struct smtp_server_cmd_ctx *cmd,
-                  struct smtp_server_cmd_rcpt *data)
-{
-       struct cmd_rcpt_context *rcpt_cmd;
-
-       /* queue command (pipeline) */
-       rcpt_cmd = p_new(cmd->pool, struct cmd_rcpt_context, 1);
-       rcpt_cmd->cmd = cmd;
-       rcpt_cmd->data = data;
-       rcpt_cmd->client = client;
-
-       smtp_server_command_add_hook(cmd->cmd, SMTP_SERVER_COMMAND_HOOK_REPLIED,
-                                    cmd_rcpt_replied, rcpt_cmd);
-
-       rcpt_cmd->cmd_proxied = smtp_client_command_rcpt_submit(
-               client->proxy_conn, 0, data->path, &data->params,
-               cmd_rcpt_proxy_cb, rcpt_cmd);
-       return 0;
-}
index 13613b5cf69be9449717e31e78335a4c0b350b20..300323ca4f060670c17b27aa086f01fe90973723 100644 (file)
@@ -316,3 +316,68 @@ int cmd_mail_relay(struct client *client, struct smtp_server_cmd_ctx *cmd,
                cmd_mail_proxy_cb, mail_cmd);
        return 0;
 }
+
+/*
+ * RCPT command
+ */
+
+struct cmd_rcpt_context {
+       struct client *client;
+       struct smtp_server_cmd_ctx *cmd;
+       struct smtp_server_cmd_rcpt *data;
+
+       struct smtp_client_command *cmd_proxied;
+};
+
+static void
+cmd_rcpt_replied(struct smtp_server_cmd_ctx *cmd ATTR_UNUSED,
+                struct cmd_rcpt_context *rcpt_cmd)
+{
+       if (rcpt_cmd->cmd_proxied != NULL)
+               smtp_client_command_abort(&rcpt_cmd->cmd_proxied);
+}
+
+static void cmd_rcpt_proxy_cb(const struct smtp_reply *proxy_reply,
+                             struct cmd_rcpt_context *rcpt_cmd)
+{
+       struct smtp_server_cmd_ctx *cmd = rcpt_cmd->cmd;
+       struct client *client = rcpt_cmd->client;
+       struct smtp_reply reply;
+
+       /* finished proxying MAIL command to relay server */
+       i_assert(rcpt_cmd != NULL);
+       rcpt_cmd->cmd_proxied = NULL;
+
+       if (!client_command_handle_proxy_reply(client, proxy_reply, &reply))
+               return;
+
+       if ((proxy_reply->status / 100) == 2) {
+               /* the default 2.0.0 code won't do */
+               if (!smtp_reply_has_enhanced_code(proxy_reply))
+                       reply.enhanced_code = SMTP_REPLY_ENH_CODE(2, 1, 5);
+       }
+
+       /* forward reply */
+       smtp_server_reply_forward(cmd, &reply);
+}
+
+int cmd_rcpt_relay(struct client *client, struct smtp_server_cmd_ctx *cmd,
+                  struct smtp_server_cmd_rcpt *data)
+{
+       struct cmd_rcpt_context *rcpt_cmd;
+
+       /* queue command (pipeline) */
+       rcpt_cmd = p_new(cmd->pool, struct cmd_rcpt_context, 1);
+       rcpt_cmd->cmd = cmd;
+       rcpt_cmd->data = data;
+       rcpt_cmd->client = client;
+
+       smtp_server_command_add_hook(cmd->cmd, SMTP_SERVER_COMMAND_HOOK_REPLIED,
+                                    cmd_rcpt_replied, rcpt_cmd);
+
+       rcpt_cmd->cmd_proxied = smtp_client_command_rcpt_submit(
+               client->proxy_conn, 0, data->path, &data->params,
+               cmd_rcpt_proxy_cb, rcpt_cmd);
+       return 0;
+}
+
index a6fbd6cbc5526cc1fa9ee39ad80617b1a31673cb..d97497f16d2870dc9187dd5bb9bcd9f6140345f8 100644 (file)
@@ -5,5 +5,7 @@ int cmd_helo_relay(struct client *client, struct smtp_server_cmd_ctx *cmd,
                   struct smtp_server_cmd_helo *data);
 int cmd_mail_relay(struct client *client, struct smtp_server_cmd_ctx *cmd,
                   struct smtp_server_cmd_mail *data);
+int cmd_rcpt_relay(struct client *client, struct smtp_server_cmd_ctx *cmd,
+                  struct smtp_server_cmd_rcpt *data);
 
 #endif
index 81aae8a818b6950d4815d4c166a62bc2f06609bd..7a9357822c5e613a61f186db05c3cd84189e4798 100644 (file)
@@ -4,8 +4,6 @@
 bool client_command_handle_proxy_reply(struct client *client,
        const struct smtp_reply *reply, struct smtp_reply *reply_r);
 
-int cmd_rcpt_relay(struct client *client, struct smtp_server_cmd_ctx *cmd,
-                  struct smtp_server_cmd_rcpt *data);
 int cmd_rset_relay(struct client *client, struct smtp_server_cmd_ctx *cmd);
 int cmd_data_relay(struct client *client, struct smtp_server_cmd_ctx *cmd,
                   struct smtp_server_transaction *trans,