comparison src/mail/ngx_mail_handler.c @ 9236:d9a52ebb9b00

Mail: max_commands directive. The directive specifies the maximum number of commands allowed during authentication, after which the connection is closed. The default limit is 1000, which is not expected to affect any well-behaving clients, since authentication usually requires at most several commands, though will effectively stop malicious clients from flooding the server with with commands.
author Maxim Dounin <mdounin@mdounin.ru>
date Sat, 30 Mar 2024 05:05:53 +0300
parents 9ca12c957304
children
comparison
equal deleted inserted replaced
9235:d7fd0acdea64 9236:d9a52ebb9b00
894 if (rc == NGX_ERROR) { 894 if (rc == NGX_ERROR) {
895 ngx_mail_close_connection(c); 895 ngx_mail_close_connection(c);
896 return NGX_ERROR; 896 return NGX_ERROR;
897 } 897 }
898 898
899 s->commands++;
900
901 if (s->commands > cscf->max_commands) {
902
903 ngx_log_error(NGX_LOG_INFO, c->log, 0,
904 "client sent too many commands");
905
906 s->quit = 1;
907
908 return NGX_MAIL_PARSE_INVALID_COMMAND;
909 }
910
899 return NGX_OK; 911 return NGX_OK;
900 } 912 }
901 913
902 914
903 void 915 void