Skip to content

Commit

Permalink
q/proxy: check client is alive b4 sending cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
msimerson committed Mar 12, 2024
1 parent b48a1fe commit ca844ae
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
3 changes: 1 addition & 2 deletions plugins/queue/smtp_forward.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,7 @@ exports.queue_forward = function (next, connection) {
);

function get_rs () {
if (txn) return txn.results;
return connection.results;
return connection?.transaction?.results ? connection.transaction.results : connection.results
}

function dead_sender () {
Expand Down
11 changes: 10 additions & 1 deletion plugins/queue/smtp_proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,22 @@ exports.hook_mail = function (next, connection, params) {
exports.hook_rcpt_ok = (next, connection, recipient) => {
const { smtp_client } = connection.notes;
if (!smtp_client) return next();
if (smtp_client.is_dead_sender(this, connection)) {
delete connection.notes.smtp_client;
return;
}
smtp_client.next = next;
smtp_client.send_command('RCPT', `TO:${recipient.format(!smtp_client.smtp_utf8)}`);
}

exports.hook_data = (next, connection) => {
const { smtp_client } = connection.notes;
if (!smtp_client) return next();

if (smtp_client.is_dead_sender(this, connection)) {
delete connection.notes.smtp_client;
return;
}
smtp_client.next = next;
smtp_client.send_command("DATA");
}
Expand All @@ -96,11 +105,11 @@ exports.hook_queue = function (next, connection) {
const { smtp_client } = connection.notes;
if (!smtp_client) return next();

smtp_client.next = next;
if (smtp_client.is_dead_sender(this, connection)) {
delete connection.notes.smtp_client;
return;
}
smtp_client.next = next;
smtp_client.start_data(connection.transaction.message_stream);
}

Expand Down

0 comments on commit ca844ae

Please sign in to comment.