Skip to content

Commit

Permalink
lmtp: proxy: Merged lmtp_proxy_add_rcpt() into lmtp_proxy_rcpt().
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanbosch committed Dec 7, 2017
1 parent 11bb115 commit 0e0ce84
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 32 deletions.
48 changes: 22 additions & 26 deletions src/lmtp/lmtp-proxy.c
Expand Up @@ -414,35 +414,15 @@ lmtp_proxy_rcpt_cb(const struct smtp_reply *proxy_reply,
rcpt->rcpt_to_failed = !smtp_reply_is_success(proxy_reply);
}

int lmtp_proxy_add_rcpt(struct lmtp_proxy *proxy,
const struct smtp_address *address,
const struct lmtp_proxy_rcpt_settings *set)
{
struct lmtp_proxy_connection *conn;
struct lmtp_proxy_recipient *rcpt;

conn = lmtp_proxy_get_connection(proxy, set);
if (conn->failed)
return -1;

rcpt = p_new(proxy->pool, struct lmtp_proxy_recipient, 1);
rcpt->idx = array_count(&proxy->rcpt_to);
rcpt->conn = conn;
rcpt->address = smtp_address_clone(proxy->pool, address);
array_append(&proxy->rcpt_to, &rcpt, 1);

smtp_client_transaction_add_rcpt(conn->lmtp_trans, address,
&set->params, lmtp_proxy_rcpt_cb, lmtp_proxy_data_cb, rcpt);
return 0;
}

int lmtp_proxy_rcpt(struct client *client,
struct smtp_address *address,
const char *username, const char *detail, char delim,
struct smtp_params_rcpt *params)
{
struct auth_master_connection *auth_conn;
struct lmtp_proxy_rcpt_settings set;
struct lmtp_proxy_connection *conn;
struct lmtp_proxy_recipient *rcpt;
struct auth_user_info info;
struct mail_storage_service_input input;
const char *const *fields, *errstr, *orig_username = username;
Expand Down Expand Up @@ -547,10 +527,26 @@ int lmtp_proxy_rcpt(struct client *client,
lmtp_proxy_mail_from(client->proxy, client->state.mail_from,
&client->state.mail_params);
}
if (lmtp_proxy_add_rcpt(client->proxy, address, &set) < 0)
client_send_line(client, "451 4.4.0 Remote server not answering");
else
client_send_line(client, "250 2.1.5 OK");

conn = lmtp_proxy_get_connection(client->proxy, &set);
if (conn->failed) {
client_send_line(client,
"451 4.4.0 Remote server not answering");
pool_unref(&pool);
return -1;
}

rcpt = p_new(client->proxy->pool, struct lmtp_proxy_recipient, 1);
rcpt->idx = array_count(&client->proxy->rcpt_to);
rcpt->conn = conn;
rcpt->address = smtp_address_clone(client->proxy->pool, address);
array_append(&client->proxy->rcpt_to, &rcpt, 1);

smtp_client_transaction_add_rcpt(conn->lmtp_trans,
address, &set.params,
lmtp_proxy_rcpt_cb, lmtp_proxy_data_cb, rcpt);

client_send_line(client, "250 2.1.5 OK");
pool_unref(&pool);
return 1;
}
Expand Down
6 changes: 0 additions & 6 deletions src/lmtp/lmtp-proxy.h
Expand Up @@ -37,12 +37,6 @@ void lmtp_proxy_deinit(struct lmtp_proxy **proxy);

unsigned int lmtp_proxy_rcpt_count(struct client *client);

/* Add a new recipient. Returns -1 if we already know that the destination
host can't be reached. */
int lmtp_proxy_add_rcpt(struct lmtp_proxy *proxy,
const struct smtp_address *address,
const struct lmtp_proxy_rcpt_settings *set);

int lmtp_proxy_rcpt(struct client *client,
struct smtp_address *address,
const char *username, const char *detail, char delim,
Expand Down

0 comments on commit 0e0ce84

Please sign in to comment.