comparison src/http/modules/ngx_http_secure_link_module.c @ 598:be70f83b184f NGINX_0_8_51

nginx 0.8.51 *) Change: the "secure_link_expires" directive has been canceled. *) Change: a logging level of resolver errors has been lowered from "alert" to "error". *) Feature: now a listen socket "ssl" parameter may be set several times.
author Igor Sysoev <http://sysoev.ru>
date Mon, 27 Sep 2010 00:00:00 +0400
parents 6c96fdd2dfc3
children d0f7a625f27c
comparison
equal deleted inserted replaced
597:1695031dbfed 598:be70f83b184f
12 12
13 typedef struct { 13 typedef struct {
14 ngx_http_complex_value_t *variable; 14 ngx_http_complex_value_t *variable;
15 ngx_http_complex_value_t *md5; 15 ngx_http_complex_value_t *md5;
16 ngx_str_t secret; 16 ngx_str_t secret;
17 ngx_flag_t expires;
18 } ngx_http_secure_link_conf_t; 17 } ngx_http_secure_link_conf_t;
19 18
20 19
21 typedef struct { 20 typedef struct {
22 ngx_str_t expires; 21 ngx_str_t expires;
36 35
37 static ngx_command_t ngx_http_secure_link_commands[] = { 36 static ngx_command_t ngx_http_secure_link_commands[] = {
38 37
39 { ngx_string("secure_link"), 38 { ngx_string("secure_link"),
40 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, 39 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
41 ngx_http_set_comlex_value_slot, 40 ngx_http_set_complex_value_slot,
42 NGX_HTTP_LOC_CONF_OFFSET, 41 NGX_HTTP_LOC_CONF_OFFSET,
43 offsetof(ngx_http_secure_link_conf_t, variable), 42 offsetof(ngx_http_secure_link_conf_t, variable),
44 NULL }, 43 NULL },
45 44
46 { ngx_string("secure_link_md5"), 45 { ngx_string("secure_link_md5"),
47 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, 46 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
48 ngx_http_set_comlex_value_slot, 47 ngx_http_set_complex_value_slot,
49 NGX_HTTP_LOC_CONF_OFFSET, 48 NGX_HTTP_LOC_CONF_OFFSET,
50 offsetof(ngx_http_secure_link_conf_t, md5), 49 offsetof(ngx_http_secure_link_conf_t, md5),
51 NULL },
52
53 { ngx_string("secure_link_expires"),
54 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
55 ngx_conf_set_flag_slot,
56 NGX_HTTP_LOC_CONF_OFFSET,
57 offsetof(ngx_http_secure_link_conf_t, expires),
58 NULL }, 50 NULL },
59 51
60 { ngx_string("secure_link_secret"), 52 { ngx_string("secure_link_secret"),
61 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, 53 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
62 ngx_conf_set_str_slot, 54 ngx_conf_set_str_slot,
139 expires = 0; 131 expires = 0;
140 132
141 if (p) { 133 if (p) {
142 val.len = p++ - val.data; 134 val.len = p++ - val.data;
143 135
144 if (conf->expires) { 136 expires = ngx_atotm(p, last - p);
145 expires = ngx_atotm(p, last - p); 137 if (expires <= 0) {
146 if (expires <= 0) { 138 goto not_found;
147 goto not_found; 139 }
148 } 140
149 141 ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_secure_link_ctx_t));
150 ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_secure_link_ctx_t)); 142 if (ctx == NULL) {
151 if (ctx == NULL) { 143 return NGX_ERROR;
152 return NGX_ERROR; 144 }
153 } 145
154 146 ngx_http_set_ctx(r, ctx, ngx_http_secure_link_module);
155 ngx_http_set_ctx(r, ctx, ngx_http_secure_link_module); 147
156 148 ctx->expires.len = last - p;
157 ctx->expires.len = last - p; 149 ctx->expires.data = p;
158 ctx->expires.data = p;
159 }
160 } 150 }
161 151
162 if (val.len > 24) { 152 if (val.len > 24) {
163 goto not_found; 153 goto not_found;
164 } 154 }
315 * conf->variable = NULL; 305 * conf->variable = NULL;
316 * conf->md5 = NULL; 306 * conf->md5 = NULL;
317 * conf->secret = { 0, NULL }; 307 * conf->secret = { 0, NULL };
318 */ 308 */
319 309
320 conf->expires = NGX_CONF_UNSET;
321
322 return conf; 310 return conf;
323 } 311 }
324 312
325 313
326 static char * 314 static char *
336 } 324 }
337 325
338 if (conf->md5 == NULL) { 326 if (conf->md5 == NULL) {
339 conf->md5 = prev->md5; 327 conf->md5 = prev->md5;
340 } 328 }
341
342 ngx_conf_merge_value(conf->expires, prev->expires, 0);
343 329
344 return NGX_CONF_OK; 330 return NGX_CONF_OK;
345 } 331 }
346 332
347 333