comparison src/http/modules/ngx_http_access_module.c @ 6996:72188d1bcab5

Access: simplified rule parser code.
author Ruslan Ermilov <ru@nginx.com>
date Mon, 15 May 2017 17:16:32 +0300
parents 06c227e9edd0
children
comparison
equal deleted inserted replaced
6995:eb5d119323d8 6996:72188d1bcab5
307 #endif 307 #endif
308 #if (NGX_HAVE_UNIX_DOMAIN) 308 #if (NGX_HAVE_UNIX_DOMAIN)
309 ngx_http_access_rule_un_t *rule_un; 309 ngx_http_access_rule_un_t *rule_un;
310 #endif 310 #endif
311 311
312 all = 0;
312 ngx_memzero(&cidr, sizeof(ngx_cidr_t)); 313 ngx_memzero(&cidr, sizeof(ngx_cidr_t));
313 314
314 value = cf->args->elts; 315 value = cf->args->elts;
315 316
316 all = (value[1].len == 3 && ngx_strcmp(value[1].data, "all") == 0); 317 if (value[1].len == 3 && ngx_strcmp(value[1].data, "all") == 0) {
317 318 all = 1;
318 if (!all) { 319
319 320 #if (NGX_HAVE_UNIX_DOMAIN)
320 #if (NGX_HAVE_UNIX_DOMAIN) 321 } else if (value[1].len == 5 && ngx_strcmp(value[1].data, "unix:") == 0) {
321 322 cidr.family = AF_UNIX;
322 if (value[1].len == 5 && ngx_strcmp(value[1].data, "unix:") == 0) { 323 #endif
323 cidr.family = AF_UNIX; 324
324 rc = NGX_OK; 325 } else {
325
326 } else {
327 rc = ngx_ptocidr(&value[1], &cidr);
328 }
329
330 #else
331 rc = ngx_ptocidr(&value[1], &cidr); 326 rc = ngx_ptocidr(&value[1], &cidr);
332 #endif
333 327
334 if (rc == NGX_ERROR) { 328 if (rc == NGX_ERROR) {
335 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, 329 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
336 "invalid parameter \"%V\"", &value[1]); 330 "invalid parameter \"%V\"", &value[1]);
337 return NGX_CONF_ERROR; 331 return NGX_CONF_ERROR;