Mercurial > hg > nginx
comparison src/http/modules/ngx_http_userid_filter_module.c @ 1805:bb72f7518992
use ngx_http_server_addr()
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Sat, 29 Dec 2007 16:00:34 +0000 |
parents | 555ee689cecc |
children | 220f5e8603d0 |
comparison
equal
deleted
inserted
replaced
1804:d457a1576532 | 1805:bb72f7518992 |
---|---|
298 | 298 |
299 static ngx_int_t | 299 static ngx_int_t |
300 ngx_http_userid_set_uid(ngx_http_request_t *r, ngx_http_userid_ctx_t *ctx, | 300 ngx_http_userid_set_uid(ngx_http_request_t *r, ngx_http_userid_ctx_t *ctx, |
301 ngx_http_userid_conf_t *conf) | 301 ngx_http_userid_conf_t *conf) |
302 { | 302 { |
303 u_char *cookie, *p; | 303 u_char *cookie, *p; |
304 size_t len; | 304 size_t len; |
305 socklen_t slen; | 305 ngx_str_t src, dst; |
306 struct sockaddr_in sin; | 306 ngx_table_elt_t *set_cookie, *p3p; |
307 ngx_str_t src, dst; | |
308 ngx_table_elt_t *set_cookie, *p3p; | |
309 | 307 |
310 /* | 308 /* |
311 * TODO: in the threaded mode the sequencers should be in TLS and their | 309 * TODO: in the threaded mode the sequencers should be in TLS and their |
312 * ranges should be divided between threads | 310 * ranges should be divided between threads |
313 */ | 311 */ |
325 ctx->uid_set[3] = sequencer_v1; | 323 ctx->uid_set[3] = sequencer_v1; |
326 sequencer_v1 += 0x100; | 324 sequencer_v1 += 0x100; |
327 | 325 |
328 } else { | 326 } else { |
329 if (conf->service == NGX_CONF_UNSET) { | 327 if (conf->service == NGX_CONF_UNSET) { |
330 if (r->in_addr == 0) { | 328 if (ngx_http_server_addr(r, NULL) != NGX_OK) { |
331 slen = sizeof(struct sockaddr_in); | 329 return NGX_ERROR; |
332 if (getsockname(r->connection->fd, | |
333 (struct sockaddr *) &sin, &slen) | |
334 == -1) | |
335 { | |
336 ngx_connection_error(r->connection, ngx_socket_errno, | |
337 "getsockname() failed"); | |
338 return NGX_ERROR; | |
339 } | |
340 | |
341 r->in_addr = sin.sin_addr.s_addr; | |
342 } | 330 } |
343 | 331 |
344 ctx->uid_set[0] = htonl(r->in_addr); | 332 ctx->uid_set[0] = htonl(r->in_addr); |
345 | 333 |
346 } else { | 334 } else { |