Access: simplified rule parser code.

This commit is contained in:
Ruslan Ermilov 2017-05-15 17:16:32 +03:00
parent 83cd4390c2
commit 96fb77a64c
2 changed files with 16 additions and 28 deletions

View File

@ -309,28 +309,22 @@ ngx_http_access_rule(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
ngx_http_access_rule_un_t *rule_un;
#endif
all = 0;
ngx_memzero(&cidr, sizeof(ngx_cidr_t));
value = cf->args->elts;
all = (value[1].len == 3 && ngx_strcmp(value[1].data, "all") == 0);
if (!all) {
if (value[1].len == 3 && ngx_strcmp(value[1].data, "all") == 0) {
all = 1;
#if (NGX_HAVE_UNIX_DOMAIN)
if (value[1].len == 5 && ngx_strcmp(value[1].data, "unix:") == 0) {
cidr.family = AF_UNIX;
rc = NGX_OK;
} else {
rc = ngx_ptocidr(&value[1], &cidr);
}
#else
rc = ngx_ptocidr(&value[1], &cidr);
} else if (value[1].len == 5 && ngx_strcmp(value[1].data, "unix:") == 0) {
cidr.family = AF_UNIX;
#endif
} else {
rc = ngx_ptocidr(&value[1], &cidr);
if (rc == NGX_ERROR) {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
"invalid parameter \"%V\"", &value[1]);

View File

@ -299,28 +299,22 @@ ngx_stream_access_rule(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
ngx_stream_access_rule_un_t *rule_un;
#endif
all = 0;
ngx_memzero(&cidr, sizeof(ngx_cidr_t));
value = cf->args->elts;
all = (value[1].len == 3 && ngx_strcmp(value[1].data, "all") == 0);
if (!all) {
if (value[1].len == 3 && ngx_strcmp(value[1].data, "all") == 0) {
all = 1;
#if (NGX_HAVE_UNIX_DOMAIN)
if (value[1].len == 5 && ngx_strcmp(value[1].data, "unix:") == 0) {
cidr.family = AF_UNIX;
rc = NGX_OK;
} else {
rc = ngx_ptocidr(&value[1], &cidr);
}
#else
rc = ngx_ptocidr(&value[1], &cidr);
} else if (value[1].len == 5 && ngx_strcmp(value[1].data, "unix:") == 0) {
cidr.family = AF_UNIX;
#endif
} else {
rc = ngx_ptocidr(&value[1], &cidr);
if (rc == NGX_ERROR) {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
"invalid parameter \"%V\"", &value[1]);