Mercurial > hg > nginx
diff src/mail/ngx_mail_handler.c @ 7844:ec1071830799
Mail: max_errors directive.
Similarly to smtpd_hard_error_limit in Postfix and smtp_max_unknown_commands
in Exim, specifies the number of errors after which the connection is closed.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Wed, 19 May 2021 03:13:31 +0300 |
parents | 2851e4c7de03 |
children | 0aaa09927703 |
line wrap: on
line diff
--- a/src/mail/ngx_mail_handler.c Wed May 19 03:13:28 2021 +0300 +++ b/src/mail/ngx_mail_handler.c Wed May 19 03:13:31 2021 +0300 @@ -874,7 +874,20 @@ return NGX_MAIL_PARSE_INVALID_COMMAND; } - if (rc == NGX_IMAP_NEXT || rc == NGX_MAIL_PARSE_INVALID_COMMAND) { + if (rc == NGX_MAIL_PARSE_INVALID_COMMAND) { + + s->errors++; + + if (s->errors >= cscf->max_errors) { + ngx_log_error(NGX_LOG_INFO, c->log, 0, + "client sent too many invalid commands"); + s->quit = 1; + } + + return rc; + } + + if (rc == NGX_IMAP_NEXT) { return rc; }