Mercurial > hg > nginx
comparison src/http/modules/ngx_http_access_module.c @ 2537:a472d954c534
prepare ngx_ptocidr() for IPv6
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 24 Feb 2009 14:01:40 +0000 |
parents | 2e91aecb9e57 |
children | c7d57b539248 |
comparison
equal
deleted
inserted
replaced
2536:a6d6d762c554 | 2537:a472d954c534 |
---|---|
139 { | 139 { |
140 ngx_http_access_loc_conf_t *alcf = conf; | 140 ngx_http_access_loc_conf_t *alcf = conf; |
141 | 141 |
142 ngx_int_t rc; | 142 ngx_int_t rc; |
143 ngx_str_t *value; | 143 ngx_str_t *value; |
144 ngx_inet_cidr_t in_cidr; | 144 ngx_cidr_t cidr; |
145 ngx_http_access_rule_t *rule; | 145 ngx_http_access_rule_t *rule; |
146 | 146 |
147 if (alcf->rules == NULL) { | 147 if (alcf->rules == NULL) { |
148 alcf->rules = ngx_array_create(cf->pool, 4, | 148 alcf->rules = ngx_array_create(cf->pool, 4, |
149 sizeof(ngx_http_access_rule_t)); | 149 sizeof(ngx_http_access_rule_t)); |
166 rule->addr = 0; | 166 rule->addr = 0; |
167 | 167 |
168 return NGX_CONF_OK; | 168 return NGX_CONF_OK; |
169 } | 169 } |
170 | 170 |
171 rc = ngx_ptocidr(&value[1], &in_cidr); | 171 rc = ngx_ptocidr(&value[1], &cidr); |
172 | 172 |
173 if (rc == NGX_ERROR) { | 173 if (rc == NGX_ERROR) { |
174 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "invalid parameter \"%V\"", | 174 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "invalid parameter \"%V\"", |
175 &value[1]); | 175 &value[1]); |
176 return NGX_CONF_ERROR; | 176 return NGX_CONF_ERROR; |
177 } | 177 } |
178 | 178 |
179 if (cidr.family != AF_INET) { | |
180 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
181 "\"allow\" supports IPv4 only"); | |
182 return NGX_CONF_ERROR; | |
183 } | |
184 | |
179 if (rc == NGX_DONE) { | 185 if (rc == NGX_DONE) { |
180 ngx_conf_log_error(NGX_LOG_WARN, cf, 0, | 186 ngx_conf_log_error(NGX_LOG_WARN, cf, 0, |
181 "low address bits of %V are meaningless", &value[1]); | 187 "low address bits of %V are meaningless", &value[1]); |
182 } | 188 } |
183 | 189 |
184 rule->mask = in_cidr.mask; | 190 rule->mask = cidr.u.in.mask; |
185 rule->addr = in_cidr.addr; | 191 rule->addr = cidr.u.in.addr; |
186 | 192 |
187 return NGX_CONF_OK; | 193 return NGX_CONF_OK; |
188 } | 194 } |
189 | 195 |
190 | 196 |