Skip to content

Commit

Permalink
submission: Move client_proxy_start() to submission-backend-relay.c.
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanbosch authored and villesavolainen committed Feb 12, 2019
1 parent 46d8457 commit 453b47c
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 34 deletions.
38 changes: 38 additions & 0 deletions src/submission/submission-backend-relay.c
Expand Up @@ -677,3 +677,41 @@ int cmd_quit_relay(struct client *client, struct smtp_server_cmd_ctx *cmd)
relay_cmd_quit_proxy(quit_cmd);
return 0;
}

/*
* Relay backend
*/

static void client_proxy_ready_cb(const struct smtp_reply *reply,
void *context)
{
struct client *client = context;
enum smtp_capability caps;

/* check proxy status */
if ((reply->status / 100) != 2) {
i_error("Failed to establish relay connection: %s",
smtp_reply_log(reply));
client_destroy(client,
"4.4.0", "Failed to establish relay connection");
return;
}

/* propagate capabilities */
caps = smtp_client_connection_get_capabilities(client->proxy_conn);
caps |= SMTP_CAPABILITY_AUTH | SMTP_CAPABILITY_PIPELINING |
SMTP_CAPABILITY_SIZE | SMTP_CAPABILITY_ENHANCEDSTATUSCODES |
SMTP_CAPABILITY_CHUNKING | SMTP_CAPABILITY_BURL |
SMTP_CAPABILITY_VRFY;
caps &= SUBMISSION_SUPPORTED_SMTP_CAPABILITIES;
smtp_server_connection_set_capabilities(client->conn, caps);

/* now that we know our capabilities, commence server protocol dialog */
smtp_server_connection_resume(client->conn);
}

void client_proxy_start(struct client *client)
{
smtp_client_connection_connect(client->proxy_conn,
client_proxy_ready_cb, client);
}
2 changes: 2 additions & 0 deletions src/submission/submission-backend-relay.h
Expand Up @@ -16,4 +16,6 @@ int cmd_vrfy_relay(struct client *client, struct smtp_server_cmd_ctx *cmd,
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 client_proxy_start(struct client *client);

#endif
35 changes: 1 addition & 34 deletions src/submission/submission-client.c
Expand Up @@ -23,6 +23,7 @@
#include "smtp-client.h"
#include "smtp-client-connection.h"

#include "submission-backend-relay.h"
#include "submission-commands.h"
#include "submission-settings.h"

Expand Down Expand Up @@ -82,40 +83,6 @@ static const char *client_remote_id(struct client *client)
return addr;
}

static void client_proxy_ready_cb(const struct smtp_reply *reply,
void *context)
{
struct client *client = context;
enum smtp_capability caps;

/* check proxy status */
if ((reply->status / 100) != 2) {
i_error("Failed to establish relay connection: %s",
smtp_reply_log(reply));
client_destroy(client,
"4.4.0", "Failed to establish relay connection");
return;
}

/* propagate capabilities */
caps = smtp_client_connection_get_capabilities(client->proxy_conn);
caps |= SMTP_CAPABILITY_AUTH | SMTP_CAPABILITY_PIPELINING |
SMTP_CAPABILITY_SIZE | SMTP_CAPABILITY_ENHANCEDSTATUSCODES |
SMTP_CAPABILITY_CHUNKING | SMTP_CAPABILITY_BURL |
SMTP_CAPABILITY_VRFY;
caps &= SUBMISSION_SUPPORTED_SMTP_CAPABILITIES;
smtp_server_connection_set_capabilities(client->conn, caps);

/* now that we know our capabilities, commence server protocol dialog */
smtp_server_connection_resume(client->conn);
}

static void client_proxy_start(struct client *client)
{
smtp_client_connection_connect(client->proxy_conn,
client_proxy_ready_cb, client);
}

static void client_proxy_create(struct client *client,
const struct submission_settings *set)
{
Expand Down

0 comments on commit 453b47c

Please sign in to comment.