Mercurial > hg > nginx
comparison src/http/modules/ngx_http_realip_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 |
---|---|
280 { | 280 { |
281 ngx_http_realip_loc_conf_t *rlcf = conf; | 281 ngx_http_realip_loc_conf_t *rlcf = conf; |
282 | 282 |
283 ngx_int_t rc; | 283 ngx_int_t rc; |
284 ngx_str_t *value; | 284 ngx_str_t *value; |
285 ngx_inet_cidr_t in_cidr; | 285 ngx_cidr_t cidr; |
286 ngx_http_realip_from_t *from; | 286 ngx_http_realip_from_t *from; |
287 | 287 |
288 if (rlcf->from == NULL) { | 288 if (rlcf->from == NULL) { |
289 rlcf->from = ngx_array_create(cf->pool, 2, | 289 rlcf->from = ngx_array_create(cf->pool, 2, |
290 sizeof(ngx_http_realip_from_t)); | 290 sizeof(ngx_http_realip_from_t)); |
298 return NGX_CONF_ERROR; | 298 return NGX_CONF_ERROR; |
299 } | 299 } |
300 | 300 |
301 value = cf->args->elts; | 301 value = cf->args->elts; |
302 | 302 |
303 rc = ngx_ptocidr(&value[1], &in_cidr); | 303 rc = ngx_ptocidr(&value[1], &cidr); |
304 | 304 |
305 if (rc == NGX_ERROR) { | 305 if (rc == NGX_ERROR) { |
306 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "invalid parameter \"%V\"", | 306 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "invalid parameter \"%V\"", |
307 &value[1]); | 307 &value[1]); |
308 return NGX_CONF_ERROR; | 308 return NGX_CONF_ERROR; |
309 } | 309 } |
310 | 310 |
311 if (cidr.family != AF_INET) { | |
312 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
313 "\"realip_from\" supports IPv4 only"); | |
314 return NGX_CONF_ERROR; | |
315 } | |
316 | |
311 if (rc == NGX_DONE) { | 317 if (rc == NGX_DONE) { |
312 ngx_conf_log_error(NGX_LOG_WARN, cf, 0, | 318 ngx_conf_log_error(NGX_LOG_WARN, cf, 0, |
313 "low address bits of %V are meaningless", &value[1]); | 319 "low address bits of %V are meaningless", &value[1]); |
314 } | 320 } |
315 | 321 |
316 from->mask = in_cidr.mask; | 322 from->mask = cidr.u.in.mask; |
317 from->addr = in_cidr.addr; | 323 from->addr = cidr.u.in.addr; |
318 | 324 |
319 return NGX_CONF_OK; | 325 return NGX_CONF_OK; |
320 } | 326 } |
321 | 327 |
322 | 328 |