comparison src/mail/ngx_mail_core_module.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 2af1287d2da7
children
comparison
equal deleted inserted replaced
9235:d7fd0acdea64 9236:d9a52ebb9b00
90 ngx_conf_set_num_slot, 90 ngx_conf_set_num_slot,
91 NGX_MAIL_SRV_CONF_OFFSET, 91 NGX_MAIL_SRV_CONF_OFFSET,
92 offsetof(ngx_mail_core_srv_conf_t, max_errors), 92 offsetof(ngx_mail_core_srv_conf_t, max_errors),
93 NULL }, 93 NULL },
94 94
95 { ngx_string("max_commands"),
96 NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_TAKE1,
97 ngx_conf_set_num_slot,
98 NGX_MAIL_SRV_CONF_OFFSET,
99 offsetof(ngx_mail_core_srv_conf_t, max_commands),
100 NULL },
101
95 ngx_null_command 102 ngx_null_command
96 }; 103 };
97 104
98 105
99 static ngx_mail_module_t ngx_mail_core_module_ctx = { 106 static ngx_mail_module_t ngx_mail_core_module_ctx = {
169 176
170 cscf->timeout = NGX_CONF_UNSET_MSEC; 177 cscf->timeout = NGX_CONF_UNSET_MSEC;
171 cscf->resolver_timeout = NGX_CONF_UNSET_MSEC; 178 cscf->resolver_timeout = NGX_CONF_UNSET_MSEC;
172 179
173 cscf->max_errors = NGX_CONF_UNSET_UINT; 180 cscf->max_errors = NGX_CONF_UNSET_UINT;
181 cscf->max_commands = NGX_CONF_UNSET_UINT;
174 182
175 cscf->resolver = NGX_CONF_UNSET_PTR; 183 cscf->resolver = NGX_CONF_UNSET_PTR;
176 184
177 cscf->file_name = cf->conf_file->file.name.data; 185 cscf->file_name = cf->conf_file->file.name.data;
178 cscf->line = cf->conf_file->line; 186 cscf->line = cf->conf_file->line;
190 ngx_conf_merge_msec_value(conf->timeout, prev->timeout, 60000); 198 ngx_conf_merge_msec_value(conf->timeout, prev->timeout, 60000);
191 ngx_conf_merge_msec_value(conf->resolver_timeout, prev->resolver_timeout, 199 ngx_conf_merge_msec_value(conf->resolver_timeout, prev->resolver_timeout,
192 30000); 200 30000);
193 201
194 ngx_conf_merge_uint_value(conf->max_errors, prev->max_errors, 5); 202 ngx_conf_merge_uint_value(conf->max_errors, prev->max_errors, 5);
203 ngx_conf_merge_uint_value(conf->max_commands, prev->max_commands, 1000);
195 204
196 ngx_conf_merge_str_value(conf->server_name, prev->server_name, ""); 205 ngx_conf_merge_str_value(conf->server_name, prev->server_name, "");
197 206
198 if (conf->server_name.len == 0) { 207 if (conf->server_name.len == 0) {
199 conf->server_name = cf->cycle->hostname; 208 conf->server_name = cf->cycle->hostname;