Mercurial > hg > nginx
comparison src/http/modules/ngx_http_userid_filter_module.c @ 2528:c1975ccd0215
axe r->in_addr
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 23 Feb 2009 21:05:10 +0000 |
parents | 2a92804f4109 |
children | 507fc5ac9839 |
comparison
equal
deleted
inserted
replaced
2527:53e73282785f | 2528:c1975ccd0215 |
---|---|
358 | 358 |
359 static ngx_int_t | 359 static ngx_int_t |
360 ngx_http_userid_set_uid(ngx_http_request_t *r, ngx_http_userid_ctx_t *ctx, | 360 ngx_http_userid_set_uid(ngx_http_request_t *r, ngx_http_userid_ctx_t *ctx, |
361 ngx_http_userid_conf_t *conf) | 361 ngx_http_userid_conf_t *conf) |
362 { | 362 { |
363 u_char *cookie, *p; | 363 u_char *cookie, *p; |
364 size_t len; | 364 size_t len; |
365 ngx_str_t src, dst; | 365 ngx_str_t src, dst; |
366 ngx_table_elt_t *set_cookie, *p3p; | 366 ngx_table_elt_t *set_cookie, *p3p; |
367 ngx_connection_t *c; | |
368 struct sockaddr_in *sin; | |
369 #if (NGX_HAVE_INET6) | |
370 struct sockaddr_in6 *sin6; | |
371 #endif | |
372 | |
367 /* | 373 /* |
368 * TODO: in the threaded mode the sequencers should be in TLS and their | 374 * TODO: in the threaded mode the sequencers should be in TLS and their |
369 * ranges should be divided between threads | 375 * ranges should be divided between threads |
370 */ | 376 */ |
371 | 377 |
386 if (conf->service == NGX_CONF_UNSET) { | 392 if (conf->service == NGX_CONF_UNSET) { |
387 if (ngx_http_server_addr(r, NULL) != NGX_OK) { | 393 if (ngx_http_server_addr(r, NULL) != NGX_OK) { |
388 return NGX_ERROR; | 394 return NGX_ERROR; |
389 } | 395 } |
390 | 396 |
391 ctx->uid_set[0] = htonl(r->in_addr); | 397 c = r->connection; |
398 | |
399 switch (c->local_sockaddr->sa_family) { | |
400 | |
401 #if (NGX_HAVE_INET6) | |
402 case AF_INET6: | |
403 sin6 = (struct sockaddr_in6 *) c->local_sockaddr; | |
404 | |
405 p = (u_char *) &ctx->uid_set[0]; | |
406 | |
407 *p++ = sin6->sin6_addr.s6_addr[12]; | |
408 *p++ = sin6->sin6_addr.s6_addr[13]; | |
409 *p++ = sin6->sin6_addr.s6_addr[14]; | |
410 *p = sin6->sin6_addr.s6_addr[15]; | |
411 | |
412 break; | |
413 #endif | |
414 default: /* AF_INET */ | |
415 sin = (struct sockaddr_in *) c->local_sockaddr; | |
416 ctx->uid_set[0] = sin->sin_addr.s_addr; | |
417 break; | |
418 } | |
392 | 419 |
393 } else { | 420 } else { |
394 ctx->uid_set[0] = htonl(conf->service); | 421 ctx->uid_set[0] = htonl(conf->service); |
395 } | 422 } |
396 | 423 |