From: Stephan Bosch Date: Sun, 15 Jul 2018 17:06:34 +0000 (+0200) Subject: submission: Move relay part of NOOP command to submission-backend-relay.c. X-Git-Tag: 2.3.9~1330 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4db72b61f38e393dc35aa46e828cd4aa2eb6b8e4;p=thirdparty%2Fdovecot%2Fcore.git submission: Move relay part of NOOP command to submission-backend-relay.c. --- diff --git a/src/submission/Makefile.am b/src/submission/Makefile.am index b531a62c96..3121552b8d 100644 --- a/src/submission/Makefile.am +++ b/src/submission/Makefile.am @@ -34,7 +34,6 @@ submission_DEPENDENCIES = \ $(LIBDOVECOT_DEPS) cmds = \ - cmd-noop.c \ cmd-quit.c submission_SOURCES = \ diff --git a/src/submission/cmd-noop.c b/src/submission/cmd-noop.c deleted file mode 100644 index 393d5e9c83..0000000000 --- a/src/submission/cmd-noop.c +++ /dev/null @@ -1,47 +0,0 @@ -/* Copyright (c) 2013-2018 Dovecot authors, see the included COPYING file */ - -#include "submission-common.h" -#include "smtp-client.h" -#include "smtp-client-connection.h" - -#include "submission-commands.h" - -/* - * NOOP command - */ - -struct cmd_noop_context { - struct client *client; - struct smtp_server_cmd_ctx *cmd; - struct smtp_client_command *cmd_proxied; -}; - -static void cmd_noop_proxy_cb(const struct smtp_reply *proxy_reply, - struct cmd_noop_context *noop_cmd) -{ - struct smtp_server_cmd_ctx *cmd = noop_cmd->cmd; - struct client *client = noop_cmd->client; - struct smtp_reply reply; - - if (!client_command_handle_proxy_reply(client, proxy_reply, &reply)) - return; - - if ((proxy_reply->status / 100) == 2) { - smtp_server_reply(cmd, 250, "2.0.0", "OK"); - } else { - smtp_server_reply_forward(cmd, &reply); - } -} - -int cmd_noop_relay(struct client *client, struct smtp_server_cmd_ctx *cmd) -{ - struct cmd_noop_context *noop_cmd; - - noop_cmd = p_new(cmd->pool, struct cmd_noop_context, 1); - noop_cmd->client = client; - noop_cmd->cmd = cmd; - - noop_cmd->cmd_proxied = smtp_client_command_noop_submit - (client->proxy_conn, 0, cmd_noop_proxy_cb, noop_cmd); - return 0; -} diff --git a/src/submission/submission-backend-relay.c b/src/submission/submission-backend-relay.c index 960e6b579d..88b7e9a0f2 100644 --- a/src/submission/submission-backend-relay.c +++ b/src/submission/submission-backend-relay.c @@ -537,3 +537,42 @@ int cmd_vrfy_relay(struct client *client, struct smtp_server_cmd_ctx *cmd, return 0; } +/* + * NOOP command + */ + +struct cmd_noop_context { + struct client *client; + struct smtp_server_cmd_ctx *cmd; + struct smtp_client_command *cmd_proxied; +}; + +static void cmd_noop_proxy_cb(const struct smtp_reply *proxy_reply, + struct cmd_noop_context *noop_cmd) +{ + struct smtp_server_cmd_ctx *cmd = noop_cmd->cmd; + struct client *client = noop_cmd->client; + struct smtp_reply reply; + + if (!client_command_handle_proxy_reply(client, proxy_reply, &reply)) + return; + + if ((proxy_reply->status / 100) == 2) { + smtp_server_reply(cmd, 250, "2.0.0", "OK"); + } else { + smtp_server_reply_forward(cmd, &reply); + } +} + +int cmd_noop_relay(struct client *client, struct smtp_server_cmd_ctx *cmd) +{ + struct cmd_noop_context *noop_cmd; + + noop_cmd = p_new(cmd->pool, struct cmd_noop_context, 1); + noop_cmd->client = client; + noop_cmd->cmd = cmd; + + noop_cmd->cmd_proxied = smtp_client_command_noop_submit + (client->proxy_conn, 0, cmd_noop_proxy_cb, noop_cmd); + return 0; +} diff --git a/src/submission/submission-backend-relay.h b/src/submission/submission-backend-relay.h index f7f1f8c228..9f2cc258a3 100644 --- a/src/submission/submission-backend-relay.h +++ b/src/submission/submission-backend-relay.h @@ -13,5 +13,6 @@ int cmd_data_relay(struct client *client, struct smtp_server_cmd_ctx *cmd, struct istream *data_input); int cmd_vrfy_relay(struct client *client, struct smtp_server_cmd_ctx *cmd, const char *param); +int cmd_noop_relay(struct client *client, struct smtp_server_cmd_ctx *cmd); #endif diff --git a/src/submission/submission-commands.h b/src/submission/submission-commands.h index 3945d0b1d2..4d3e990415 100644 --- a/src/submission/submission-commands.h +++ b/src/submission/submission-commands.h @@ -4,7 +4,6 @@ bool client_command_handle_proxy_reply(struct client *client, const struct smtp_reply *reply, struct smtp_reply *reply_r); -int cmd_noop_relay(struct client *client, struct smtp_server_cmd_ctx *cmd); int cmd_quit_relay(struct client *client, struct smtp_server_cmd_ctx *cmd); void submission_helo_reply_submit(struct smtp_server_cmd_ctx *cmd,