Mercurial > hg > nginx-quic
annotate src/http/modules/ngx_http_userid_filter_module.c @ 3720:c3a37fc8d1fe
use an empty name as default server_name instread of hostname
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Thu, 29 Jul 2010 10:00:04 +0000 |
parents | 8649a0c0f09d |
children | bfab2536197b |
rev | line source |
---|---|
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
417
diff
changeset
|
1 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
417
diff
changeset
|
2 /* |
444
42d11f017717
nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents:
441
diff
changeset
|
3 * Copyright (C) Igor Sysoev |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
417
diff
changeset
|
4 */ |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
417
diff
changeset
|
5 |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
6 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 #include <ngx_config.h> |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 #include <ngx_core.h> |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
9 #include <ngx_http.h> |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
10 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
11 |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
12 #define NGX_HTTP_USERID_OFF 0 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
13 #define NGX_HTTP_USERID_LOG 1 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
14 #define NGX_HTTP_USERID_V1 2 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
15 #define NGX_HTTP_USERID_ON 3 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
16 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
17 /* 31 Dec 2037 23:55:55 GMT */ |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
18 #define NGX_HTTP_USERID_MAX_EXPIRES 2145916555 |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
19 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
20 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
21 typedef struct { |
509 | 22 ngx_uint_t enable; |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
23 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
24 ngx_int_t service; |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
25 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
26 ngx_str_t name; |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
27 ngx_str_t domain; |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
28 ngx_str_t path; |
539 | 29 ngx_str_t p3p; |
30 | |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
31 time_t expires; |
539 | 32 |
33 u_char mark; | |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
34 } ngx_http_userid_conf_t; |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
35 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
36 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
37 typedef struct { |
461 | 38 uint32_t uid_got[4]; |
39 uint32_t uid_set[4]; | |
539 | 40 ngx_str_t cookie; |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
41 } ngx_http_userid_ctx_t; |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
42 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
43 |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
44 static ngx_http_userid_ctx_t *ngx_http_userid_get_uid(ngx_http_request_t *r, |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
45 ngx_http_userid_conf_t *conf); |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
46 static ngx_int_t ngx_http_userid_variable(ngx_http_request_t *r, |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
47 ngx_http_variable_value_t *v, ngx_str_t *name, uint32_t *uid); |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
48 static ngx_int_t ngx_http_userid_set_uid(ngx_http_request_t *r, |
499 | 49 ngx_http_userid_ctx_t *ctx, ngx_http_userid_conf_t *conf); |
3648
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
50 static ngx_int_t ngx_http_userid_create_uid(ngx_http_request_t *r, |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
51 ngx_http_userid_ctx_t *ctx, ngx_http_userid_conf_t *conf); |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
52 |
573 | 53 static ngx_int_t ngx_http_userid_add_variables(ngx_conf_t *cf); |
681 | 54 static ngx_int_t ngx_http_userid_init(ngx_conf_t *cf); |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
55 static void *ngx_http_userid_create_conf(ngx_conf_t *cf); |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
56 static char *ngx_http_userid_merge_conf(ngx_conf_t *cf, void *parent, |
499 | 57 void *child); |
58 static char *ngx_http_userid_domain(ngx_conf_t *cf, void *post, void *data); | |
59 static char *ngx_http_userid_path(ngx_conf_t *cf, void *post, void *data); | |
60 static char *ngx_http_userid_expires(ngx_conf_t *cf, ngx_command_t *cmd, | |
61 void *conf); | |
62 static char *ngx_http_userid_p3p(ngx_conf_t *cf, void *post, void *data); | |
539 | 63 static char *ngx_http_userid_mark(ngx_conf_t *cf, ngx_command_t *cmd, |
64 void *conf); | |
1651
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
65 static ngx_int_t ngx_http_userid_init_worker(ngx_cycle_t *cycle); |
539 | 66 |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
67 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
68 |
1651
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
69 static uint32_t start_value; |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
70 static uint32_t sequencer_v1 = 1; |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
71 static uint32_t sequencer_v2 = 0x03030302; |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
72 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
73 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
74 static u_char expires[] = "; expires=Thu, 31-Dec-37 23:55:55 GMT"; |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
75 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
76 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
77 static ngx_http_output_header_filter_pt ngx_http_next_header_filter; |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
78 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
79 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
80 static ngx_conf_enum_t ngx_http_userid_state[] = { |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
81 { ngx_string("off"), NGX_HTTP_USERID_OFF }, |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
82 { ngx_string("log"), NGX_HTTP_USERID_LOG }, |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
83 { ngx_string("v1"), NGX_HTTP_USERID_V1 }, |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
84 { ngx_string("on"), NGX_HTTP_USERID_ON }, |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
85 { ngx_null_string, 0 } |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
86 }; |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
87 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
88 |
461 | 89 static ngx_conf_post_handler_pt ngx_http_userid_domain_p = |
509 | 90 ngx_http_userid_domain; |
461 | 91 static ngx_conf_post_handler_pt ngx_http_userid_path_p = ngx_http_userid_path; |
92 static ngx_conf_post_handler_pt ngx_http_userid_p3p_p = ngx_http_userid_p3p; | |
412
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
93 |
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
94 |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
95 static ngx_command_t ngx_http_userid_commands[] = { |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
96 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
97 { ngx_string("userid"), |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
98 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
99 ngx_conf_set_enum_slot, |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
100 NGX_HTTP_LOC_CONF_OFFSET, |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
101 offsetof(ngx_http_userid_conf_t, enable), |
412
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
102 ngx_http_userid_state }, |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
103 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
104 { ngx_string("userid_service"), |
539 | 105 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
106 ngx_conf_set_num_slot, |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
107 NGX_HTTP_LOC_CONF_OFFSET, |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
108 offsetof(ngx_http_userid_conf_t, service), |
412
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
109 NULL }, |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
110 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
111 { ngx_string("userid_name"), |
539 | 112 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
113 ngx_conf_set_str_slot, |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
114 NGX_HTTP_LOC_CONF_OFFSET, |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
115 offsetof(ngx_http_userid_conf_t, name), |
412
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
116 NULL }, |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
117 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
118 { ngx_string("userid_domain"), |
539 | 119 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
120 ngx_conf_set_str_slot, |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
121 NGX_HTTP_LOC_CONF_OFFSET, |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
122 offsetof(ngx_http_userid_conf_t, domain), |
461 | 123 &ngx_http_userid_domain_p }, |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
124 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
125 { ngx_string("userid_path"), |
539 | 126 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
127 ngx_conf_set_str_slot, |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
128 NGX_HTTP_LOC_CONF_OFFSET, |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
129 offsetof(ngx_http_userid_conf_t, path), |
461 | 130 &ngx_http_userid_path_p }, |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
131 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
132 { ngx_string("userid_expires"), |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
133 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
410
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
134 ngx_http_userid_expires, |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
135 NGX_HTTP_LOC_CONF_OFFSET, |
410
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
136 0, |
412
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
137 NULL }, |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
138 |
461 | 139 { ngx_string("userid_p3p"), |
140 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
141 ngx_conf_set_str_slot, | |
142 NGX_HTTP_LOC_CONF_OFFSET, | |
143 offsetof(ngx_http_userid_conf_t, p3p), | |
144 &ngx_http_userid_p3p_p }, | |
145 | |
539 | 146 { ngx_string("userid_mark"), |
147 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
148 ngx_http_userid_mark, | |
149 NGX_HTTP_LOC_CONF_OFFSET, | |
150 0, | |
151 NULL }, | |
152 | |
499 | 153 ngx_null_command |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
154 }; |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
155 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
156 |
667 | 157 static ngx_http_module_t ngx_http_userid_filter_module_ctx = { |
573 | 158 ngx_http_userid_add_variables, /* preconfiguration */ |
681 | 159 ngx_http_userid_init, /* postconfiguration */ |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
160 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
161 NULL, /* create main configuration */ |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
162 NULL, /* init main configuration */ |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
163 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
164 NULL, /* create server configuration */ |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
165 NULL, /* merge server configuration */ |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
166 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
167 ngx_http_userid_create_conf, /* create location configration */ |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
168 ngx_http_userid_merge_conf /* merge location configration */ |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
169 }; |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
170 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
171 |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
172 ngx_module_t ngx_http_userid_filter_module = { |
509 | 173 NGX_MODULE_V1, |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
174 &ngx_http_userid_filter_module_ctx, /* module context */ |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
175 ngx_http_userid_commands, /* module directives */ |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
176 NGX_HTTP_MODULE, /* module type */ |
541 | 177 NULL, /* init master */ |
681 | 178 NULL, /* init module */ |
1651
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
179 ngx_http_userid_init_worker, /* init process */ |
541 | 180 NULL, /* init thread */ |
181 NULL, /* exit thread */ | |
182 NULL, /* exit process */ | |
183 NULL, /* exit master */ | |
184 NGX_MODULE_V1_PADDING | |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
185 }; |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
186 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
187 |
573 | 188 static ngx_str_t ngx_http_userid_got = ngx_string("uid_got"); |
189 static ngx_str_t ngx_http_userid_set = ngx_string("uid_set"); | |
190 | |
191 | |
499 | 192 static ngx_int_t |
193 ngx_http_userid_filter(ngx_http_request_t *r) | |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
194 { |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
195 ngx_http_userid_ctx_t *ctx; |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
196 ngx_http_userid_conf_t *conf; |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
197 |
597 | 198 if (r != r->main) { |
509 | 199 return ngx_http_next_header_filter(r); |
200 } | |
201 | |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
202 conf = ngx_http_get_module_loc_conf(r, ngx_http_userid_filter_module); |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
203 |
3647 | 204 if (conf->enable < NGX_HTTP_USERID_V1) { |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
205 return ngx_http_next_header_filter(r); |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
206 } |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
207 |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
208 ctx = ngx_http_userid_get_uid(r, conf); |
499 | 209 |
210 if (ctx == NULL) { | |
211 return NGX_ERROR; | |
212 } | |
213 | |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
214 if (ngx_http_userid_set_uid(r, ctx, conf) == NGX_OK) { |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
215 return ngx_http_next_header_filter(r); |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
216 } |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
217 |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
218 return NGX_ERROR; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
219 } |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
220 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
221 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
222 static ngx_int_t |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
223 ngx_http_userid_got_variable(ngx_http_request_t *r, |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
224 ngx_http_variable_value_t *v, uintptr_t data) |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
225 { |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
226 ngx_http_userid_ctx_t *ctx; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
227 ngx_http_userid_conf_t *conf; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
228 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
229 conf = ngx_http_get_module_loc_conf(r->main, ngx_http_userid_filter_module); |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
230 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
231 if (conf->enable == NGX_HTTP_USERID_OFF) { |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
232 v->not_found = 1; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
233 return NGX_OK; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
234 } |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
235 |
3659
7e69af2dd93c
set uid values for main request only
Igor Sysoev <igor@sysoev.ru>
parents:
3649
diff
changeset
|
236 ctx = ngx_http_userid_get_uid(r->main, conf); |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
237 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
238 if (ctx == NULL) { |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
239 return NGX_ERROR; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
240 } |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
241 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
242 if (ctx->uid_got[3] != 0) { |
3659
7e69af2dd93c
set uid values for main request only
Igor Sysoev <igor@sysoev.ru>
parents:
3649
diff
changeset
|
243 return ngx_http_userid_variable(r->main, v, &conf->name, ctx->uid_got); |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
244 } |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
245 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
246 v->not_found = 1; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
247 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
248 return NGX_OK; |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
249 } |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
250 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
251 |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
252 static ngx_int_t |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
253 ngx_http_userid_set_variable(ngx_http_request_t *r, |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
254 ngx_http_variable_value_t *v, uintptr_t data) |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
255 { |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
256 ngx_http_userid_ctx_t *ctx; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
257 ngx_http_userid_conf_t *conf; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
258 |
3659
7e69af2dd93c
set uid values for main request only
Igor Sysoev <igor@sysoev.ru>
parents:
3649
diff
changeset
|
259 conf = ngx_http_get_module_loc_conf(r->main, ngx_http_userid_filter_module); |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
260 |
3648
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
261 if (conf->enable < NGX_HTTP_USERID_V1) { |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
262 v->not_found = 1; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
263 return NGX_OK; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
264 } |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
265 |
3659
7e69af2dd93c
set uid values for main request only
Igor Sysoev <igor@sysoev.ru>
parents:
3649
diff
changeset
|
266 ctx = ngx_http_userid_get_uid(r->main, conf); |
3648
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
267 |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
268 if (ctx == NULL) { |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
269 return NGX_ERROR; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
270 } |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
271 |
3661
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
272 if (ngx_http_userid_create_uid(r->main, ctx, conf) != NGX_OK) { |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
273 return NGX_ERROR; |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
274 } |
3648
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
275 |
3661
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
276 if (ctx->uid_set[3] == 0) { |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
277 v->not_found = 1; |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
278 return NGX_OK; |
3648
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
279 } |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
280 |
3659
7e69af2dd93c
set uid values for main request only
Igor Sysoev <igor@sysoev.ru>
parents:
3649
diff
changeset
|
281 return ngx_http_userid_variable(r->main, v, &conf->name, ctx->uid_set); |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
282 } |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
283 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
284 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
285 static ngx_http_userid_ctx_t * |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
286 ngx_http_userid_get_uid(ngx_http_request_t *r, ngx_http_userid_conf_t *conf) |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
287 { |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
288 ngx_int_t n; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
289 ngx_str_t src, dst; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
290 ngx_table_elt_t **cookies; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
291 ngx_http_userid_ctx_t *ctx; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
292 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
293 ctx = ngx_http_get_module_ctx(r, ngx_http_userid_filter_module); |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
294 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
295 if (ctx) { |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
296 return ctx; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
297 } |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
298 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
299 if (ctx == NULL) { |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
300 ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_userid_ctx_t)); |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
301 if (ctx == NULL) { |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
302 return NULL; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
303 } |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
304 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
305 ngx_http_set_ctx(r, ctx, ngx_http_userid_filter_module); |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
306 } |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
307 |
509 | 308 n = ngx_http_parse_multi_header_lines(&r->headers_in.cookies, &conf->name, |
539 | 309 &ctx->cookie); |
509 | 310 if (n == NGX_DECLINED) { |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
311 return ctx; |
509 | 312 } |
461 | 313 |
539 | 314 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
315 "uid cookie: \"%V\"", &ctx->cookie); | |
316 | |
317 if (ctx->cookie.len < 22) { | |
509 | 318 cookies = r->headers_in.cookies.elts; |
319 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
320 "client sent too short userid cookie \"%V\"", | |
321 &cookies[n]->value); | |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
322 return ctx; |
509 | 323 } |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
324 |
539 | 325 src = ctx->cookie; |
326 | |
509 | 327 /* |
539 | 328 * we have to limit the encoded string to 22 characters because |
329 * 1) cookie may be marked by "userid_mark", | |
330 * 2) and there are already the millions cookies with a garbage | |
331 * instead of the correct base64 trail "==" | |
509 | 332 */ |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
333 |
509 | 334 src.len = 22; |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
335 |
509 | 336 dst.data = (u_char *) ctx->uid_got; |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
337 |
509 | 338 if (ngx_decode_base64(&dst, &src) == NGX_ERROR) { |
339 cookies = r->headers_in.cookies.elts; | |
340 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
341 "client sent invalid userid cookie \"%V\"", | |
342 &cookies[n]->value); | |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
343 return ctx; |
509 | 344 } |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
345 |
509 | 346 ngx_log_debug4(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
347 "uid: %08XD%08XD%08XD%08XD", | |
348 ctx->uid_got[0], ctx->uid_got[1], | |
349 ctx->uid_got[2], ctx->uid_got[3]); | |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
350 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
351 return ctx; |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
352 } |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
353 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
354 |
499 | 355 static ngx_int_t |
356 ngx_http_userid_set_uid(ngx_http_request_t *r, ngx_http_userid_ctx_t *ctx, | |
357 ngx_http_userid_conf_t *conf) | |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
358 { |
3648
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
359 u_char *cookie, *p; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
360 size_t len; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
361 ngx_str_t src, dst; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
362 ngx_table_elt_t *set_cookie, *p3p; |
2528 | 363 |
3661
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
364 if (ngx_http_userid_create_uid(r, ctx, conf) != NGX_OK) { |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
365 return NGX_ERROR; |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
366 } |
539 | 367 |
3661
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
368 if (ctx->uid_set[3] == 0) { |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
369 return NGX_OK; |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
370 } |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
371 |
461 | 372 len = conf->name.len + 1 + ngx_base64_encoded_length(16) + conf->path.len; |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
373 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
374 if (conf->expires) { |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
375 len += sizeof(expires) - 1 + 2; |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
376 } |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
377 |
479 | 378 if (conf->domain.len) { |
461 | 379 len += conf->domain.len; |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
380 } |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
381 |
2049 | 382 cookie = ngx_pnalloc(r->pool, len); |
499 | 383 if (cookie == NULL) { |
412
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
384 return NGX_ERROR; |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
385 } |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
386 |
573 | 387 p = ngx_copy(cookie, conf->name.data, conf->name.len); |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
388 *p++ = '='; |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
389 |
539 | 390 if (ctx->uid_got[3] == 0) { |
391 src.len = 16; | |
392 src.data = (u_char *) ctx->uid_set; | |
393 dst.data = p; | |
394 | |
395 ngx_encode_base64(&dst, &src); | |
396 | |
397 p += dst.len; | |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
398 |
539 | 399 if (conf->mark) { |
400 *(p - 2) = conf->mark; | |
401 } | |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
402 |
539 | 403 } else { |
404 p = ngx_cpymem(p, ctx->cookie.data, 22); | |
405 *p++ = conf->mark; | |
406 *p++ = '='; | |
407 } | |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
408 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
409 if (conf->expires == NGX_HTTP_USERID_MAX_EXPIRES) { |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
410 p = ngx_cpymem(p, expires, sizeof(expires) - 1); |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
411 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
412 } else if (conf->expires) { |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
413 p = ngx_cpymem(p, expires, sizeof("; expires=") - 1); |
455 | 414 p = ngx_http_cookie_time(p, ngx_time() + conf->expires); |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
415 } |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
416 |
573 | 417 p = ngx_copy(p, conf->domain.data, conf->domain.len); |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
418 |
573 | 419 p = ngx_copy(p, conf->path.data, conf->path.len); |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
420 |
499 | 421 set_cookie = ngx_list_push(&r->headers_out.headers); |
422 if (set_cookie == NULL) { | |
412
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
423 return NGX_ERROR; |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
424 } |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
425 |
509 | 426 set_cookie->hash = 1; |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3509
diff
changeset
|
427 ngx_str_set(&set_cookie->key, "Set-Cookie"); |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
428 set_cookie->value.len = p - cookie; |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
429 set_cookie->value.data = cookie; |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
430 |
461 | 431 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
432 "uid cookie: \"%V\"", &set_cookie->value); | |
433 | |
479 | 434 if (conf->p3p.len == 0) { |
461 | 435 return NGX_OK; |
436 } | |
437 | |
499 | 438 p3p = ngx_list_push(&r->headers_out.headers); |
439 if (p3p == NULL) { | |
461 | 440 return NGX_ERROR; |
441 } | |
442 | |
509 | 443 p3p->hash = 1; |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3509
diff
changeset
|
444 ngx_str_set(&p3p->key, "P3P"); |
461 | 445 p3p->value = conf->p3p; |
446 | |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
447 return NGX_OK; |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
448 } |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
449 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
450 |
499 | 451 static ngx_int_t |
3648
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
452 ngx_http_userid_create_uid(ngx_http_request_t *r, ngx_http_userid_ctx_t *ctx, |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
453 ngx_http_userid_conf_t *conf) |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
454 { |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
455 ngx_connection_t *c; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
456 struct sockaddr_in *sin; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
457 #if (NGX_HAVE_INET6) |
3649
fd6f0f1a9055
fix building without IPv6 after the previous commit
Igor Sysoev <igor@sysoev.ru>
parents:
3648
diff
changeset
|
458 u_char *p; |
3648
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
459 struct sockaddr_in6 *sin6; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
460 #endif |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
461 |
3661
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
462 if (ctx->uid_set[3] != 0) { |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
463 return NGX_OK; |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
464 } |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
465 |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
466 if (ctx->uid_got[3] != 0) { |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
467 |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
468 if (conf->mark == '\0' |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
469 || (ctx->cookie.len > 23 |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
470 && ctx->cookie.data[22] == conf->mark |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
471 && ctx->cookie.data[23] == '=')) |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
472 { |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
473 return NGX_OK; |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
474 } |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
475 |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
476 ctx->uid_set[0] = ctx->uid_got[0]; |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
477 ctx->uid_set[1] = ctx->uid_got[1]; |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
478 ctx->uid_set[2] = ctx->uid_got[2]; |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
479 ctx->uid_set[3] = ctx->uid_got[3]; |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
480 |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
481 return NGX_OK; |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
482 } |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
483 |
3648
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
484 /* |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
485 * TODO: in the threaded mode the sequencers should be in TLS and their |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
486 * ranges should be divided between threads |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
487 */ |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
488 |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
489 if (conf->enable == NGX_HTTP_USERID_V1) { |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
490 if (conf->service == NGX_CONF_UNSET) { |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
491 ctx->uid_set[0] = 0; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
492 } else { |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
493 ctx->uid_set[0] = conf->service; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
494 } |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
495 ctx->uid_set[1] = (uint32_t) ngx_time(); |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
496 ctx->uid_set[2] = start_value; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
497 ctx->uid_set[3] = sequencer_v1; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
498 sequencer_v1 += 0x100; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
499 |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
500 } else { |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
501 if (conf->service == NGX_CONF_UNSET) { |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
502 |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
503 c = r->connection; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
504 |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
505 if (ngx_connection_local_sockaddr(c, NULL, 0) != NGX_OK) { |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
506 return NGX_ERROR; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
507 } |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
508 |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
509 switch (c->local_sockaddr->sa_family) { |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
510 |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
511 #if (NGX_HAVE_INET6) |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
512 case AF_INET6: |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
513 sin6 = (struct sockaddr_in6 *) c->local_sockaddr; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
514 |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
515 p = (u_char *) &ctx->uid_set[0]; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
516 |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
517 *p++ = sin6->sin6_addr.s6_addr[12]; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
518 *p++ = sin6->sin6_addr.s6_addr[13]; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
519 *p++ = sin6->sin6_addr.s6_addr[14]; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
520 *p = sin6->sin6_addr.s6_addr[15]; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
521 |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
522 break; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
523 #endif |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
524 default: /* AF_INET */ |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
525 sin = (struct sockaddr_in *) c->local_sockaddr; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
526 ctx->uid_set[0] = sin->sin_addr.s_addr; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
527 break; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
528 } |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
529 |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
530 } else { |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
531 ctx->uid_set[0] = htonl(conf->service); |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
532 } |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
533 |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
534 ctx->uid_set[1] = htonl((uint32_t) ngx_time()); |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
535 ctx->uid_set[2] = htonl(start_value); |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
536 ctx->uid_set[3] = htonl(sequencer_v2); |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
537 sequencer_v2 += 0x100; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
538 if (sequencer_v2 < 0x03030302) { |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
539 sequencer_v2 = 0x03030302; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
540 } |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
541 } |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
542 |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
543 return NGX_OK; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
544 } |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
545 |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
546 |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
547 static ngx_int_t |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
548 ngx_http_userid_variable(ngx_http_request_t *r, ngx_http_variable_value_t *v, |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
549 ngx_str_t *name, uint32_t *uid) |
410
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
550 { |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
551 v->len = name->len + sizeof("=00001111222233334444555566667777") - 1; |
2049 | 552 v->data = ngx_pnalloc(r->pool, v->len); |
573 | 553 if (v->data == NULL) { |
554 return NGX_ERROR; | |
555 } | |
556 | |
657 | 557 v->valid = 1; |
1565 | 558 v->no_cacheable = 0; |
657 | 559 v->not_found = 0; |
560 | |
573 | 561 ngx_sprintf(v->data, "%V=%08XD%08XD%08XD%08XD", |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
562 name, uid[0], uid[1], uid[2], uid[3]); |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
563 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
564 return NGX_OK; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
565 } |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
566 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
567 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
568 static ngx_int_t |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
569 ngx_http_userid_add_variables(ngx_conf_t *cf) |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
570 { |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
571 ngx_http_variable_t *var; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
572 |
3522
d24f030507cd
allow to use $uid_got in SSI and perl module
Igor Sysoev <igor@sysoev.ru>
parents:
3516
diff
changeset
|
573 var = ngx_http_add_variable(cf, &ngx_http_userid_got, 0); |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
574 if (var == NULL) { |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
575 return NGX_ERROR; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
576 } |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
577 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
578 var->get_handler = ngx_http_userid_got_variable; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
579 |
3661
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
580 var = ngx_http_add_variable(cf, &ngx_http_userid_set, 0); |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
581 if (var == NULL) { |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
582 return NGX_ERROR; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
583 } |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
584 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
585 var->get_handler = ngx_http_userid_set_variable; |
573 | 586 |
587 return NGX_OK; | |
588 } | |
589 | |
590 | |
499 | 591 static void * |
592 ngx_http_userid_create_conf(ngx_conf_t *cf) | |
577 | 593 { |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
594 ngx_http_userid_conf_t *conf; |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
595 |
499 | 596 conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_userid_conf_t)); |
597 if (conf == NULL) { | |
2912
c7d57b539248
return NULL instead of NGX_CONF_ERROR on a create conf failure
Igor Sysoev <igor@sysoev.ru>
parents:
2857
diff
changeset
|
598 return NULL; |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
599 } |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
600 |
479 | 601 /* |
602 * set by ngx_pcalloc(): | |
603 * | |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3509
diff
changeset
|
604 * conf->name = { 0, NULL }; |
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3509
diff
changeset
|
605 * conf->domain = { 0, NULL }; |
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3509
diff
changeset
|
606 * conf->path = { 0, NULL }; |
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3509
diff
changeset
|
607 * conf->p3p = { 0, NULL }; |
479 | 608 */ |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
609 |
509 | 610 conf->enable = NGX_CONF_UNSET_UINT; |
410
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
611 conf->service = NGX_CONF_UNSET; |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
612 conf->expires = NGX_CONF_UNSET; |
539 | 613 conf->mark = (u_char) '\xFF'; |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
614 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
615 return conf; |
577 | 616 } |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
617 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
618 |
499 | 619 static char * |
620 ngx_http_userid_merge_conf(ngx_conf_t *cf, void *parent, void *child) | |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
621 { |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
622 ngx_http_userid_conf_t *prev = parent; |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
623 ngx_http_userid_conf_t *conf = child; |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
624 |
663 | 625 ngx_conf_merge_uint_value(conf->enable, prev->enable, |
626 NGX_HTTP_USERID_OFF); | |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
627 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
628 ngx_conf_merge_str_value(conf->name, prev->name, "uid"); |
479 | 629 ngx_conf_merge_str_value(conf->domain, prev->domain, ""); |
461 | 630 ngx_conf_merge_str_value(conf->path, prev->path, "; path=/"); |
479 | 631 ngx_conf_merge_str_value(conf->p3p, prev->p3p, ""); |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
632 |
410
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
633 ngx_conf_merge_value(conf->service, prev->service, NGX_CONF_UNSET); |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
634 ngx_conf_merge_sec_value(conf->expires, prev->expires, 0); |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
635 |
539 | 636 if (conf->mark == (u_char) '\xFF') { |
637 if (prev->mark == (u_char) '\xFF') { | |
638 conf->mark = '\0'; | |
639 } else { | |
640 conf->mark = prev->mark; | |
641 } | |
642 } | |
643 | |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
644 return NGX_CONF_OK; |
410
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
645 } |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
646 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
647 |
681 | 648 static ngx_int_t |
649 ngx_http_userid_init(ngx_conf_t *cf) | |
650 { | |
651 ngx_http_next_header_filter = ngx_http_top_header_filter; | |
652 ngx_http_top_header_filter = ngx_http_userid_filter; | |
653 | |
654 return NGX_OK; | |
655 } | |
656 | |
657 | |
499 | 658 static char * |
659 ngx_http_userid_domain(ngx_conf_t *cf, void *post, void *data) | |
412
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
660 { |
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
661 ngx_str_t *domain = data; |
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
662 |
461 | 663 u_char *p, *new; |
664 | |
503 | 665 if (ngx_strcmp(domain->data, "none") == 0) { |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3509
diff
changeset
|
666 ngx_str_set(domain, ""); |
461 | 667 return NGX_CONF_OK; |
412
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
668 } |
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
669 |
2049 | 670 new = ngx_pnalloc(cf->pool, sizeof("; domain=") - 1 + domain->len); |
499 | 671 if (new == NULL) { |
461 | 672 return NGX_CONF_ERROR; |
673 } | |
674 | |
675 p = ngx_cpymem(new, "; domain=", sizeof("; domain=") - 1); | |
501 | 676 ngx_memcpy(p, domain->data, domain->len); |
461 | 677 |
678 domain->len += sizeof("; domain=") - 1; | |
679 domain->data = new; | |
680 | |
681 return NGX_CONF_OK; | |
682 } | |
683 | |
684 | |
499 | 685 static char * |
686 ngx_http_userid_path(ngx_conf_t *cf, void *post, void *data) | |
461 | 687 { |
688 ngx_str_t *path = data; | |
689 | |
690 u_char *p, *new; | |
691 | |
2049 | 692 new = ngx_pnalloc(cf->pool, sizeof("; path=") - 1 + path->len); |
499 | 693 if (new == NULL) { |
461 | 694 return NGX_CONF_ERROR; |
695 } | |
696 | |
697 p = ngx_cpymem(new, "; path=", sizeof("; path=") - 1); | |
501 | 698 ngx_memcpy(p, path->data, path->len); |
461 | 699 |
700 path->len += sizeof("; path=") - 1; | |
701 path->data = new; | |
702 | |
412
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
703 return NGX_CONF_OK; |
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
704 } |
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
705 |
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
706 |
499 | 707 static char * |
708 ngx_http_userid_expires(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
709 { |
410
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
710 ngx_http_userid_conf_t *ucf = conf; |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
711 |
539 | 712 ngx_str_t *value; |
410
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
713 |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
714 if (ucf->expires != NGX_CONF_UNSET) { |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
715 return "is duplicate"; |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
716 } |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
717 |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
718 value = cf->args->elts; |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
719 |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
720 if (ngx_strcmp(value[1].data, "max") == 0) { |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
721 ucf->expires = NGX_HTTP_USERID_MAX_EXPIRES; |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
722 return NGX_CONF_OK; |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
723 } |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
724 |
410
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
725 if (ngx_strcmp(value[1].data, "off") == 0) { |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
726 ucf->expires = 0; |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
727 return NGX_CONF_OK; |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
728 } |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
729 |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
730 ucf->expires = ngx_parse_time(&value[1], 1); |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
731 if (ucf->expires == NGX_ERROR) { |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
732 return "invalid value"; |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
733 } |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
734 |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
735 if (ucf->expires == NGX_PARSE_LARGE_TIME) { |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
736 return "value must be less than 68 years"; |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
737 } |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
738 |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
739 return NGX_CONF_OK; |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
740 } |
461 | 741 |
742 | |
499 | 743 static char * |
744 ngx_http_userid_p3p(ngx_conf_t *cf, void *post, void *data) | |
461 | 745 { |
746 ngx_str_t *p3p = data; | |
747 | |
503 | 748 if (ngx_strcmp(p3p->data, "none") == 0) { |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3509
diff
changeset
|
749 ngx_str_set(p3p, ""); |
461 | 750 } |
751 | |
752 return NGX_CONF_OK; | |
753 } | |
539 | 754 |
755 | |
756 static char * | |
757 ngx_http_userid_mark(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
758 { | |
759 ngx_http_userid_conf_t *ucf = conf; | |
760 | |
761 ngx_str_t *value; | |
762 | |
763 if (ucf->mark != (u_char) '\xFF') { | |
764 return "is duplicate"; | |
765 } | |
766 | |
767 value = cf->args->elts; | |
768 | |
769 if (ngx_strcmp(value[1].data, "off") == 0) { | |
770 ucf->mark = '\0'; | |
771 return NGX_CONF_OK; | |
772 } | |
773 | |
774 if (value[1].len != 1 | |
775 || !((value[1].data[0] >= '0' && value[1].data[0] <= '9') | |
776 || (value[1].data[0] >= 'A' && value[1].data[0] <= 'Z') | |
777 || (value[1].data[0] >= 'a' && value[1].data[0] <= 'z') | |
778 || value[1].data[0] == '=')) | |
779 { | |
780 return "value must be \"off\" or a single letter, digit or \"=\""; | |
781 } | |
782 | |
783 ucf->mark = value[1].data[0]; | |
784 | |
785 return NGX_CONF_OK; | |
786 } | |
1651
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
787 |
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
788 |
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
789 static ngx_int_t |
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
790 ngx_http_userid_init_worker(ngx_cycle_t *cycle) |
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
791 { |
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
792 struct timeval tp; |
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
793 |
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
794 ngx_gettimeofday(&tp); |
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
795 |
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
796 /* use the most significant usec part that fits to 16 bits */ |
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
797 start_value = ((tp.tv_usec / 20) << 16) | ngx_pid; |
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
798 |
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
799 return NGX_OK; |
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
800 } |