Mercurial > hg > nginx
comparison src/http/modules/ngx_http_realip_module.c @ 1380:b590a528fd41
ignore meaningless bits in CIDR and warn about them
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Fri, 10 Aug 2007 13:13:28 +0000 |
parents | cec2866f29bd |
children | 2a92804f4109 |
comparison
equal
deleted
inserted
replaced
1379:cc8ac1936aa4 | 1380:b590a528fd41 |
---|---|
186 static char * | 186 static char * |
187 ngx_http_realip_from(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | 187 ngx_http_realip_from(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
188 { | 188 { |
189 ngx_http_realip_loc_conf_t *rlcf = conf; | 189 ngx_http_realip_loc_conf_t *rlcf = conf; |
190 | 190 |
191 ngx_int_t rc; | |
191 ngx_str_t *value; | 192 ngx_str_t *value; |
192 ngx_inet_cidr_t in_cidr; | 193 ngx_inet_cidr_t in_cidr; |
193 ngx_http_realip_from_t *from; | 194 ngx_http_realip_from_t *from; |
194 | 195 |
195 if (rlcf->from == NULL) { | 196 if (rlcf->from == NULL) { |
213 from->mask = 0xffffffff; | 214 from->mask = 0xffffffff; |
214 | 215 |
215 return NGX_CONF_OK; | 216 return NGX_CONF_OK; |
216 } | 217 } |
217 | 218 |
218 if (ngx_ptocidr(&value[1], &in_cidr) == NGX_ERROR) { | 219 rc = ngx_ptocidr(&value[1], &in_cidr); |
220 | |
221 if (rc == NGX_ERROR) { | |
219 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "invalid parameter \"%V\"", | 222 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "invalid parameter \"%V\"", |
220 &value[1]); | 223 &value[1]); |
221 return NGX_CONF_ERROR; | 224 return NGX_CONF_ERROR; |
225 } | |
226 | |
227 if (rc == NGX_DONE) { | |
228 ngx_conf_log_error(NGX_LOG_WARN, cf, 0, | |
229 "low address bits of %V are meaningless", &value[1]); | |
222 } | 230 } |
223 | 231 |
224 from->mask = in_cidr.mask; | 232 from->mask = in_cidr.mask; |
225 from->addr = in_cidr.addr; | 233 from->addr = in_cidr.addr; |
226 | 234 |