nginxtra 1.8.1.12 → 1.10.1.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/nginxtra +1 -1
- data/bin/nginxtra_rails +1 -1
- data/lib/nginxtra/version.rb +1 -1
- data/vendor/nginx/CHANGES +363 -25
- data/vendor/nginx/CHANGES.ru +365 -21
- data/vendor/nginx/LICENSE +2 -2
- data/vendor/nginx/auto/cc/conf +32 -0
- data/vendor/nginx/auto/cc/gcc +1 -1
- data/vendor/nginx/auto/cc/icc +2 -2
- data/vendor/nginx/auto/cc/msvc +29 -8
- data/vendor/nginx/auto/cc/name +2 -25
- data/vendor/nginx/auto/cc/sunc +3 -0
- data/vendor/nginx/auto/endianness +7 -2
- data/vendor/nginx/auto/install +60 -26
- data/vendor/nginx/auto/lib/conf +4 -4
- data/vendor/nginx/auto/lib/geoip/conf +6 -1
- data/vendor/nginx/auto/lib/libgd/conf +6 -1
- data/vendor/nginx/auto/lib/libxslt/conf +11 -2
- data/vendor/nginx/auto/lib/make +1 -1
- data/vendor/nginx/auto/lib/md5/conf +2 -2
- data/vendor/nginx/auto/lib/md5/make +2 -2
- data/vendor/nginx/auto/lib/openssl/conf +52 -3
- data/vendor/nginx/auto/lib/openssl/make +1 -1
- data/vendor/nginx/auto/lib/pcre/conf +2 -2
- data/vendor/nginx/auto/lib/pcre/make +2 -2
- data/vendor/nginx/auto/lib/perl/conf +6 -3
- data/vendor/nginx/auto/lib/perl/make +4 -1
- data/vendor/nginx/auto/lib/sha1/conf +2 -2
- data/vendor/nginx/auto/lib/sha1/make +2 -2
- data/vendor/nginx/auto/lib/zlib/conf +2 -2
- data/vendor/nginx/auto/lib/zlib/make +2 -2
- data/vendor/nginx/auto/make +281 -16
- data/vendor/nginx/auto/module +122 -0
- data/vendor/nginx/auto/modules +909 -178
- data/vendor/nginx/auto/options +81 -19
- data/vendor/nginx/auto/os/conf +9 -0
- data/vendor/nginx/auto/os/darwin +3 -0
- data/vendor/nginx/auto/os/freebsd +0 -20
- data/vendor/nginx/auto/os/linux +0 -12
- data/vendor/nginx/auto/os/win32 +5 -1
- data/vendor/nginx/auto/sources +11 -311
- data/vendor/nginx/auto/summary +1 -0
- data/vendor/nginx/auto/types/sizeof +5 -3
- data/vendor/nginx/auto/types/typedef +9 -4
- data/vendor/nginx/auto/types/uintptr_t +7 -2
- data/vendor/nginx/auto/unix +72 -12
- data/vendor/nginx/conf/fastcgi.conf +1 -0
- data/vendor/nginx/conf/fastcgi_params +1 -0
- data/vendor/nginx/conf/scgi_params +1 -0
- data/vendor/nginx/conf/uwsgi_params +1 -0
- data/vendor/nginx/configure +1 -1
- data/vendor/nginx/contrib/vim/syntax/nginx.vim +2 -2
- data/vendor/nginx/man/nginx.8 +6 -2
- data/vendor/nginx/src/core/nginx.c +281 -114
- data/vendor/nginx/src/core/nginx.h +2 -2
- data/vendor/nginx/src/core/ngx_conf_file.c +54 -13
- data/vendor/nginx/src/core/ngx_conf_file.h +8 -52
- data/vendor/nginx/src/core/ngx_config.h +0 -5
- data/vendor/nginx/src/core/ngx_connection.c +270 -37
- data/vendor/nginx/src/core/ngx_connection.h +35 -12
- data/vendor/nginx/src/core/ngx_core.h +4 -0
- data/vendor/nginx/src/core/ngx_crypt.c +2 -2
- data/vendor/nginx/src/core/ngx_cycle.c +72 -25
- data/vendor/nginx/src/core/ngx_cycle.h +28 -39
- data/vendor/nginx/src/core/ngx_file.c +14 -5
- data/vendor/nginx/src/core/ngx_file.h +2 -0
- data/vendor/nginx/src/core/ngx_hash.c +13 -1
- data/vendor/nginx/src/core/ngx_inet.c +20 -18
- data/vendor/nginx/src/core/ngx_log.c +12 -12
- data/vendor/nginx/src/core/ngx_log.h +13 -6
- data/vendor/nginx/src/core/ngx_module.c +360 -0
- data/vendor/nginx/src/core/ngx_module.h +307 -0
- data/vendor/nginx/src/core/ngx_open_file_cache.c +2 -2
- data/vendor/nginx/src/core/ngx_output_chain.c +8 -4
- data/vendor/nginx/src/core/ngx_palloc.c +42 -44
- data/vendor/nginx/src/{http/ngx_http_parse_time.c → core/ngx_parse_time.c} +2 -3
- data/vendor/nginx/src/core/ngx_parse_time.h +22 -0
- data/vendor/nginx/src/core/ngx_proxy_protocol.c +50 -1
- data/vendor/nginx/src/core/ngx_proxy_protocol.h +3 -1
- data/vendor/nginx/src/core/ngx_regex.c +1 -38
- data/vendor/nginx/src/core/ngx_resolver.c +1814 -320
- data/vendor/nginx/src/core/ngx_resolver.h +67 -10
- data/vendor/nginx/src/core/ngx_rwlock.c +120 -0
- data/vendor/nginx/src/core/ngx_rwlock.h +21 -0
- data/vendor/nginx/src/core/ngx_slab.c +6 -5
- data/vendor/nginx/src/core/ngx_string.c +1 -1
- data/vendor/nginx/src/core/ngx_syslog.c +11 -3
- data/vendor/nginx/src/core/ngx_syslog.h +2 -1
- data/vendor/nginx/src/core/ngx_thread_pool.c +4 -0
- data/vendor/nginx/src/core/ngx_times.c +2 -2
- data/vendor/nginx/src/event/modules/ngx_devpoll_module.c +3 -1
- data/vendor/nginx/src/event/modules/ngx_epoll_module.c +5 -2
- data/vendor/nginx/src/event/modules/ngx_eventport_module.c +5 -5
- data/vendor/nginx/src/event/modules/ngx_kqueue_module.c +15 -8
- data/vendor/nginx/src/event/modules/ngx_poll_module.c +0 -10
- data/vendor/nginx/src/event/modules/ngx_select_module.c +0 -10
- data/vendor/nginx/src/event/ngx_event.c +60 -103
- data/vendor/nginx/src/event/ngx_event.h +22 -26
- data/vendor/nginx/src/event/ngx_event_accept.c +414 -88
- data/vendor/nginx/src/event/ngx_event_connect.c +27 -18
- data/vendor/nginx/src/event/ngx_event_connect.h +1 -0
- data/vendor/nginx/src/event/ngx_event_openssl.c +65 -25
- data/vendor/nginx/src/event/ngx_event_openssl.h +17 -0
- data/vendor/nginx/src/event/ngx_event_openssl_stapling.c +73 -7
- data/vendor/nginx/src/event/ngx_event_pipe.c +85 -27
- data/vendor/nginx/src/event/ngx_event_pipe.h +10 -0
- data/vendor/nginx/src/http/modules/ngx_http_auth_basic_module.c +1 -1
- data/vendor/nginx/src/http/modules/ngx_http_auth_request_module.c +2 -2
- data/vendor/nginx/src/http/modules/ngx_http_chunked_filter_module.c +2 -2
- data/vendor/nginx/src/http/modules/ngx_http_dav_module.c +6 -6
- data/vendor/nginx/src/http/modules/ngx_http_fastcgi_module.c +17 -11
- data/vendor/nginx/src/http/modules/ngx_http_gzip_filter_module.c +2 -2
- data/vendor/nginx/src/http/modules/ngx_http_headers_filter_module.c +9 -9
- data/vendor/nginx/src/http/modules/ngx_http_image_filter_module.c +2 -2
- data/vendor/nginx/src/http/modules/ngx_http_limit_conn_module.c +2 -2
- data/vendor/nginx/src/http/modules/ngx_http_limit_req_module.c +0 -7
- data/vendor/nginx/src/http/modules/ngx_http_map_module.c +6 -6
- data/vendor/nginx/src/http/modules/ngx_http_memcached_module.c +2 -1
- data/vendor/nginx/src/http/modules/ngx_http_mp4_module.c +13 -13
- data/vendor/nginx/src/http/modules/ngx_http_not_modified_filter_module.c +2 -2
- data/vendor/nginx/src/http/modules/ngx_http_proxy_module.c +26 -21
- data/vendor/nginx/src/http/modules/ngx_http_random_index_module.c +1 -1
- data/vendor/nginx/src/http/modules/ngx_http_range_filter_module.c +26 -8
- data/vendor/nginx/src/http/modules/ngx_http_realip_module.c +73 -3
- data/vendor/nginx/src/http/modules/ngx_http_referer_module.c +1 -1
- data/vendor/nginx/src/http/modules/ngx_http_rewrite_module.c +6 -6
- data/vendor/nginx/src/http/modules/ngx_http_scgi_module.c +5 -3
- data/vendor/nginx/src/http/modules/ngx_http_slice_filter_module.c +526 -0
- data/vendor/nginx/src/http/modules/ngx_http_ssi_filter_module.c +7 -7
- data/vendor/nginx/src/http/modules/ngx_http_ssl_module.c +19 -16
- data/vendor/nginx/src/http/modules/ngx_http_static_module.c +1 -1
- data/vendor/nginx/src/http/modules/ngx_http_stub_status_module.c +1 -1
- data/vendor/nginx/src/http/modules/ngx_http_sub_filter_module.c +373 -173
- data/vendor/nginx/src/http/modules/ngx_http_upstream_hash_module.c +72 -46
- data/vendor/nginx/src/http/modules/ngx_http_upstream_ip_hash_module.c +18 -30
- data/vendor/nginx/src/http/modules/ngx_http_upstream_keepalive_module.c +50 -39
- data/vendor/nginx/src/http/modules/ngx_http_upstream_least_conn_module.c +38 -129
- data/vendor/nginx/src/http/modules/ngx_http_upstream_zone_module.c +246 -0
- data/vendor/nginx/src/http/modules/ngx_http_uwsgi_module.c +6 -5
- data/vendor/nginx/src/http/modules/perl/nginx.xs +9 -9
- data/vendor/nginx/src/http/ngx_http.c +46 -43
- data/vendor/nginx/src/http/ngx_http.h +4 -9
- data/vendor/nginx/src/http/ngx_http_cache.h +4 -0
- data/vendor/nginx/src/http/ngx_http_copy_filter_module.c +13 -5
- data/vendor/nginx/src/http/ngx_http_core_module.c +92 -91
- data/vendor/nginx/src/http/ngx_http_core_module.h +12 -8
- data/vendor/nginx/src/http/ngx_http_file_cache.c +61 -10
- data/vendor/nginx/src/http/ngx_http_request.c +37 -50
- data/vendor/nginx/src/http/ngx_http_request.h +10 -15
- data/vendor/nginx/src/http/ngx_http_request_body.c +64 -88
- data/vendor/nginx/src/http/ngx_http_script.c +3 -3
- data/vendor/nginx/src/http/ngx_http_special_response.c +1 -4
- data/vendor/nginx/src/http/ngx_http_upstream.c +245 -109
- data/vendor/nginx/src/http/ngx_http_upstream.h +11 -5
- data/vendor/nginx/src/http/ngx_http_upstream_round_robin.c +212 -65
- data/vendor/nginx/src/http/ngx_http_upstream_round_robin.h +66 -5
- data/vendor/nginx/src/http/ngx_http_variables.c +28 -15
- data/vendor/nginx/src/http/ngx_http_write_filter_module.c +1 -1
- data/vendor/nginx/src/http/v2/ngx_http_v2.c +4349 -0
- data/vendor/nginx/src/http/v2/ngx_http_v2.h +337 -0
- data/vendor/nginx/src/http/v2/ngx_http_v2_filter_module.c +1391 -0
- data/vendor/nginx/src/http/v2/ngx_http_v2_huff_decode.c +2714 -0
- data/vendor/nginx/src/http/v2/ngx_http_v2_huff_encode.c +254 -0
- data/vendor/nginx/src/http/v2/ngx_http_v2_module.c +469 -0
- data/vendor/nginx/src/http/{ngx_http_spdy_module.h → v2/ngx_http_v2_module.h} +10 -9
- data/vendor/nginx/src/http/v2/ngx_http_v2_table.c +349 -0
- data/vendor/nginx/src/mail/ngx_mail.c +49 -82
- data/vendor/nginx/src/mail/ngx_mail.h +16 -23
- data/vendor/nginx/src/mail/ngx_mail_auth_http_module.c +1 -1
- data/vendor/nginx/src/mail/ngx_mail_core_module.c +60 -34
- data/vendor/nginx/src/mail/ngx_mail_handler.c +17 -12
- data/vendor/nginx/src/mail/ngx_mail_proxy_module.c +1 -14
- data/vendor/nginx/src/mail/ngx_mail_smtp_handler.c +1 -1
- data/vendor/nginx/src/mail/ngx_mail_ssl_module.c +5 -5
- data/vendor/nginx/src/os/unix/ngx_atomic.h +10 -10
- data/vendor/nginx/src/os/unix/ngx_channel.h +4 -4
- data/vendor/nginx/src/os/unix/ngx_darwin_config.h +2 -0
- data/vendor/nginx/src/os/unix/ngx_darwin_init.c +1 -0
- data/vendor/nginx/src/os/unix/ngx_dlopen.c +28 -0
- data/vendor/nginx/src/os/unix/ngx_dlopen.h +31 -0
- data/vendor/nginx/src/os/unix/ngx_errno.h +1 -0
- data/vendor/nginx/src/os/unix/ngx_file_aio_read.c +1 -1
- data/vendor/nginx/src/os/unix/ngx_files.c +313 -80
- data/vendor/nginx/src/os/unix/ngx_files.h +5 -2
- data/vendor/nginx/src/os/unix/ngx_freebsd_config.h +3 -1
- data/vendor/nginx/src/os/unix/ngx_freebsd_init.c +1 -0
- data/vendor/nginx/src/os/unix/ngx_freebsd_sendfile_chain.c +13 -0
- data/vendor/nginx/src/os/unix/ngx_linux.h +0 -2
- data/vendor/nginx/src/os/unix/ngx_linux_aio_read.c +1 -1
- data/vendor/nginx/src/os/unix/ngx_linux_config.h +2 -6
- data/vendor/nginx/src/os/unix/ngx_linux_init.c +1 -33
- data/vendor/nginx/src/os/unix/ngx_linux_sendfile_chain.c +55 -12
- data/vendor/nginx/src/os/unix/ngx_os.h +3 -9
- data/vendor/nginx/src/os/unix/ngx_posix_config.h +14 -1
- data/vendor/nginx/src/os/unix/ngx_posix_init.c +2 -1
- data/vendor/nginx/src/os/unix/ngx_process.c +1 -1
- data/vendor/nginx/src/os/unix/ngx_process_cycle.c +25 -51
- data/vendor/nginx/src/os/unix/ngx_process_cycle.h +1 -0
- data/vendor/nginx/src/os/unix/ngx_readv_chain.c +24 -28
- data/vendor/nginx/src/os/unix/ngx_recv.c +30 -79
- data/vendor/nginx/src/os/unix/ngx_send.c +1 -1
- data/vendor/nginx/src/os/unix/ngx_setaffinity.c +14 -30
- data/vendor/nginx/src/os/unix/ngx_setaffinity.h +15 -1
- data/vendor/nginx/src/os/unix/ngx_solaris_config.h +2 -0
- data/vendor/nginx/src/os/unix/ngx_solaris_init.c +1 -0
- data/vendor/nginx/src/os/unix/ngx_solaris_sendfilev_chain.c +23 -0
- data/vendor/nginx/src/os/unix/ngx_sunpro_amd64.il +3 -3
- data/vendor/nginx/src/os/unix/ngx_sunpro_x86.il +3 -3
- data/vendor/nginx/src/os/unix/ngx_udp_recv.c +5 -48
- data/vendor/nginx/src/os/unix/ngx_udp_send.c +56 -0
- data/vendor/nginx/src/stream/ngx_stream.c +564 -0
- data/vendor/nginx/src/stream/ngx_stream.h +212 -0
- data/vendor/nginx/src/stream/ngx_stream_access_module.c +451 -0
- data/vendor/nginx/src/stream/ngx_stream_core_module.c +562 -0
- data/vendor/nginx/src/stream/ngx_stream_handler.c +344 -0
- data/vendor/nginx/src/stream/ngx_stream_limit_conn_module.c +632 -0
- data/vendor/nginx/src/stream/ngx_stream_proxy_module.c +1674 -0
- data/vendor/nginx/src/stream/ngx_stream_ssl_module.c +460 -0
- data/vendor/nginx/src/stream/ngx_stream_ssl_module.h +49 -0
- data/vendor/nginx/src/stream/ngx_stream_upstream.c +464 -0
- data/vendor/nginx/src/stream/ngx_stream_upstream.h +107 -0
- data/vendor/nginx/src/stream/ngx_stream_upstream_hash_module.c +656 -0
- data/vendor/nginx/src/stream/ngx_stream_upstream_least_conn_module.c +307 -0
- data/vendor/nginx/src/stream/ngx_stream_upstream_round_robin.c +702 -0
- data/vendor/nginx/src/stream/ngx_stream_upstream_round_robin.h +139 -0
- data/vendor/nginx/src/stream/ngx_stream_upstream_zone_module.c +242 -0
- metadata +39 -15
- data/vendor/nginx/src/event/modules/ngx_aio_module.c +0 -171
- data/vendor/nginx/src/event/modules/ngx_rtsig_module.c +0 -735
- data/vendor/nginx/src/http/ngx_http_spdy.c +0 -3701
- data/vendor/nginx/src/http/ngx_http_spdy.h +0 -261
- data/vendor/nginx/src/http/ngx_http_spdy_filter_module.c +0 -1222
- data/vendor/nginx/src/http/ngx_http_spdy_module.c +0 -408
- data/vendor/nginx/src/os/unix/ngx_aio_read.c +0 -109
- data/vendor/nginx/src/os/unix/ngx_aio_read_chain.c +0 -78
- data/vendor/nginx/src/os/unix/ngx_aio_write.c +0 -109
- data/vendor/nginx/src/os/unix/ngx_aio_write_chain.c +0 -100
@@ -468,12 +468,12 @@ ngx_http_ssi_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|
468
468
|
while (ctx->pos < ctx->buf->last) {
|
469
469
|
|
470
470
|
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
471
|
-
"saved: %
|
471
|
+
"saved: %uz state: %ui", ctx->saved, ctx->state);
|
472
472
|
|
473
473
|
rc = ngx_http_ssi_parse(r, ctx);
|
474
474
|
|
475
475
|
ngx_log_debug4(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
476
|
-
"parse: %
|
476
|
+
"parse: %i, looked: %uz %p-%p",
|
477
477
|
rc, ctx->looked, ctx->copy_start, ctx->copy_end);
|
478
478
|
|
479
479
|
if (rc == NGX_ERROR) {
|
@@ -485,7 +485,7 @@ ngx_http_ssi_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|
485
485
|
if (ctx->output) {
|
486
486
|
|
487
487
|
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
488
|
-
"saved: %
|
488
|
+
"saved: %uz", ctx->saved);
|
489
489
|
|
490
490
|
if (ctx->saved) {
|
491
491
|
|
@@ -1911,7 +1911,7 @@ ngx_http_ssi_regex_match(ngx_http_request_t *r, ngx_str_t *pattern,
|
|
1911
1911
|
|
1912
1912
|
if (rc < NGX_REGEX_NO_MATCHED) {
|
1913
1913
|
ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
|
1914
|
-
ngx_regex_exec_n " failed: %
|
1914
|
+
ngx_regex_exec_n " failed: %d on \"%V\" using \"%V\"",
|
1915
1915
|
rc, str, pattern);
|
1916
1916
|
return NGX_HTTP_SSI_ERROR;
|
1917
1917
|
}
|
@@ -2005,7 +2005,7 @@ ngx_http_ssi_include(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx,
|
|
2005
2005
|
|
2006
2006
|
if (uri && file) {
|
2007
2007
|
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
2008
|
-
"
|
2008
|
+
"inclusion may be either virtual=\"%V\" or file=\"%V\"",
|
2009
2009
|
uri, file);
|
2010
2010
|
return NGX_HTTP_SSI_ERROR;
|
2011
2011
|
}
|
@@ -2525,7 +2525,7 @@ ngx_http_ssi_if(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx,
|
|
2525
2525
|
}
|
2526
2526
|
|
2527
2527
|
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
2528
|
-
"
|
2528
|
+
"evaluated left: \"%V\"", &left);
|
2529
2529
|
|
2530
2530
|
if (p == last) {
|
2531
2531
|
if (left.len) {
|
@@ -2589,7 +2589,7 @@ ngx_http_ssi_if(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx,
|
|
2589
2589
|
}
|
2590
2590
|
|
2591
2591
|
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
2592
|
-
"
|
2592
|
+
"evaluated right: \"%V\"", &right);
|
2593
2593
|
|
2594
2594
|
if (noregex) {
|
2595
2595
|
if (left.len != right.len) {
|
@@ -326,10 +326,10 @@ ngx_http_ssl_alpn_select(ngx_ssl_conn_t *ssl_conn, const unsigned char **out,
|
|
326
326
|
#if (NGX_DEBUG)
|
327
327
|
unsigned int i;
|
328
328
|
#endif
|
329
|
-
#if (
|
329
|
+
#if (NGX_HTTP_V2)
|
330
330
|
ngx_http_connection_t *hc;
|
331
331
|
#endif
|
332
|
-
#if (
|
332
|
+
#if (NGX_HTTP_V2 || NGX_DEBUG)
|
333
333
|
ngx_connection_t *c;
|
334
334
|
|
335
335
|
c = ngx_ssl_get_connection(ssl_conn);
|
@@ -337,17 +337,19 @@ ngx_http_ssl_alpn_select(ngx_ssl_conn_t *ssl_conn, const unsigned char **out,
|
|
337
337
|
|
338
338
|
#if (NGX_DEBUG)
|
339
339
|
for (i = 0; i < inlen; i += in[i] + 1) {
|
340
|
-
|
341
|
-
|
340
|
+
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0,
|
341
|
+
"SSL ALPN supported by client: %*s",
|
342
|
+
(size_t) in[i], &in[i + 1]);
|
342
343
|
}
|
343
344
|
#endif
|
344
345
|
|
345
|
-
#if (
|
346
|
+
#if (NGX_HTTP_V2)
|
346
347
|
hc = c->data;
|
347
348
|
|
348
|
-
if (hc->addr_conf->
|
349
|
-
srv =
|
350
|
-
|
349
|
+
if (hc->addr_conf->http2) {
|
350
|
+
srv =
|
351
|
+
(unsigned char *) NGX_HTTP_V2_ALPN_ADVERTISE NGX_HTTP_NPN_ADVERTISE;
|
352
|
+
srvlen = sizeof(NGX_HTTP_V2_ALPN_ADVERTISE NGX_HTTP_NPN_ADVERTISE) - 1;
|
351
353
|
|
352
354
|
} else
|
353
355
|
#endif
|
@@ -364,7 +366,7 @@ ngx_http_ssl_alpn_select(ngx_ssl_conn_t *ssl_conn, const unsigned char **out,
|
|
364
366
|
}
|
365
367
|
|
366
368
|
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0,
|
367
|
-
"SSL ALPN selected: %*s", *outlen, *out);
|
369
|
+
"SSL ALPN selected: %*s", (size_t) *outlen, *out);
|
368
370
|
|
369
371
|
return SSL_TLSEXT_ERR_OK;
|
370
372
|
}
|
@@ -378,22 +380,23 @@ static int
|
|
378
380
|
ngx_http_ssl_npn_advertised(ngx_ssl_conn_t *ssl_conn,
|
379
381
|
const unsigned char **out, unsigned int *outlen, void *arg)
|
380
382
|
{
|
381
|
-
#if (
|
383
|
+
#if (NGX_HTTP_V2 || NGX_DEBUG)
|
382
384
|
ngx_connection_t *c;
|
383
385
|
|
384
386
|
c = ngx_ssl_get_connection(ssl_conn);
|
385
387
|
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "SSL NPN advertised");
|
386
388
|
#endif
|
387
389
|
|
388
|
-
#if (
|
390
|
+
#if (NGX_HTTP_V2)
|
389
391
|
{
|
390
392
|
ngx_http_connection_t *hc;
|
391
393
|
|
392
394
|
hc = c->data;
|
393
395
|
|
394
|
-
if (hc->addr_conf->
|
395
|
-
*out =
|
396
|
-
|
396
|
+
if (hc->addr_conf->http2) {
|
397
|
+
*out =
|
398
|
+
(unsigned char *) NGX_HTTP_V2_NPN_ADVERTISE NGX_HTTP_NPN_ADVERTISE;
|
399
|
+
*outlen = sizeof(NGX_HTTP_V2_NPN_ADVERTISE NGX_HTTP_NPN_ADVERTISE) - 1;
|
397
400
|
|
398
401
|
return SSL_TLSEXT_ERR_OK;
|
399
402
|
}
|
@@ -561,7 +564,7 @@ ngx_http_ssl_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child)
|
|
561
564
|
prev->prefer_server_ciphers, 0);
|
562
565
|
|
563
566
|
ngx_conf_merge_bitmask_value(conf->protocols, prev->protocols,
|
564
|
-
(NGX_CONF_BITMASK_SET|
|
567
|
+
(NGX_CONF_BITMASK_SET|NGX_SSL_TLSv1
|
565
568
|
|NGX_SSL_TLSv1_1|NGX_SSL_TLSv1_2));
|
566
569
|
|
567
570
|
ngx_conf_merge_size_value(conf->buffer_size, prev->buffer_size,
|
@@ -715,7 +718,7 @@ ngx_http_ssl_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child)
|
|
715
718
|
SSL_CTX_set_options(conf->ssl.ctx, SSL_OP_CIPHER_SERVER_PREFERENCE);
|
716
719
|
}
|
717
720
|
|
718
|
-
#
|
721
|
+
#if (OPENSSL_VERSION_NUMBER < 0x10100001L && !defined LIBRESSL_VERSION_NUMBER)
|
719
722
|
/* a temporary 512-bit RSA key is required for export versions of MSIE */
|
720
723
|
SSL_CTX_set_tmp_rsa_callback(conf->ssl.ctx, ngx_ssl_rsa512_key_callback);
|
721
724
|
#endif
|
@@ -89,7 +89,7 @@ ngx_http_stub_status_handler(ngx_http_request_t *r)
|
|
89
89
|
ngx_chain_t out;
|
90
90
|
ngx_atomic_int_t ap, hn, ac, rq, rd, wr, wa;
|
91
91
|
|
92
|
-
if (r->method
|
92
|
+
if (!(r->method & (NGX_HTTP_GET|NGX_HTTP_HEAD))) {
|
93
93
|
return NGX_HTTP_NOT_ALLOWED;
|
94
94
|
}
|
95
95
|
|
@@ -11,8 +11,32 @@
|
|
11
11
|
|
12
12
|
|
13
13
|
typedef struct {
|
14
|
-
|
14
|
+
ngx_http_complex_value_t match;
|
15
15
|
ngx_http_complex_value_t value;
|
16
|
+
} ngx_http_sub_pair_t;
|
17
|
+
|
18
|
+
|
19
|
+
typedef struct {
|
20
|
+
ngx_str_t match;
|
21
|
+
ngx_http_complex_value_t *value;
|
22
|
+
} ngx_http_sub_match_t;
|
23
|
+
|
24
|
+
|
25
|
+
typedef struct {
|
26
|
+
ngx_uint_t min_match_len;
|
27
|
+
ngx_uint_t max_match_len;
|
28
|
+
|
29
|
+
u_char index[257];
|
30
|
+
u_char shift[256];
|
31
|
+
} ngx_http_sub_tables_t;
|
32
|
+
|
33
|
+
|
34
|
+
typedef struct {
|
35
|
+
ngx_uint_t dynamic; /* unsigned dynamic:1; */
|
36
|
+
|
37
|
+
ngx_array_t *pairs;
|
38
|
+
|
39
|
+
ngx_http_sub_tables_t *tables;
|
16
40
|
|
17
41
|
ngx_hash_t types;
|
18
42
|
|
@@ -20,17 +44,11 @@ typedef struct {
|
|
20
44
|
ngx_flag_t last_modified;
|
21
45
|
|
22
46
|
ngx_array_t *types_keys;
|
47
|
+
ngx_array_t *matches;
|
23
48
|
} ngx_http_sub_loc_conf_t;
|
24
49
|
|
25
50
|
|
26
|
-
typedef enum {
|
27
|
-
sub_start_state = 0,
|
28
|
-
sub_match_state,
|
29
|
-
} ngx_http_sub_state_e;
|
30
|
-
|
31
|
-
|
32
51
|
typedef struct {
|
33
|
-
ngx_str_t match;
|
34
52
|
ngx_str_t saved;
|
35
53
|
ngx_str_t looked;
|
36
54
|
|
@@ -48,12 +66,20 @@ typedef struct {
|
|
48
66
|
ngx_chain_t *busy;
|
49
67
|
ngx_chain_t *free;
|
50
68
|
|
51
|
-
ngx_str_t
|
69
|
+
ngx_str_t *sub;
|
70
|
+
ngx_uint_t applied;
|
52
71
|
|
53
|
-
|
72
|
+
ngx_int_t offset;
|
73
|
+
ngx_uint_t index;
|
74
|
+
|
75
|
+
ngx_http_sub_tables_t *tables;
|
76
|
+
ngx_array_t *matches;
|
54
77
|
} ngx_http_sub_ctx_t;
|
55
78
|
|
56
79
|
|
80
|
+
static ngx_uint_t ngx_http_sub_cmp_index;
|
81
|
+
|
82
|
+
|
57
83
|
static ngx_int_t ngx_http_sub_output(ngx_http_request_t *r,
|
58
84
|
ngx_http_sub_ctx_t *ctx);
|
59
85
|
static ngx_int_t ngx_http_sub_parse(ngx_http_request_t *r,
|
@@ -64,6 +90,9 @@ static char * ngx_http_sub_filter(ngx_conf_t *cf, ngx_command_t *cmd,
|
|
64
90
|
static void *ngx_http_sub_create_conf(ngx_conf_t *cf);
|
65
91
|
static char *ngx_http_sub_merge_conf(ngx_conf_t *cf,
|
66
92
|
void *parent, void *child);
|
93
|
+
static void ngx_http_sub_init_tables(ngx_http_sub_tables_t *tables,
|
94
|
+
ngx_http_sub_match_t *match, ngx_uint_t n);
|
95
|
+
static ngx_int_t ngx_http_sub_cmp_matches(const void *one, const void *two);
|
67
96
|
static ngx_int_t ngx_http_sub_filter_init(ngx_conf_t *cf);
|
68
97
|
|
69
98
|
|
@@ -139,12 +168,16 @@ static ngx_http_output_body_filter_pt ngx_http_next_body_filter;
|
|
139
168
|
static ngx_int_t
|
140
169
|
ngx_http_sub_header_filter(ngx_http_request_t *r)
|
141
170
|
{
|
142
|
-
|
171
|
+
ngx_str_t *m;
|
172
|
+
ngx_uint_t i, j, n;
|
173
|
+
ngx_http_sub_ctx_t *ctx;
|
174
|
+
ngx_http_sub_pair_t *pairs;
|
175
|
+
ngx_http_sub_match_t *matches;
|
143
176
|
ngx_http_sub_loc_conf_t *slcf;
|
144
177
|
|
145
178
|
slcf = ngx_http_get_module_loc_conf(r, ngx_http_sub_filter_module);
|
146
179
|
|
147
|
-
if (slcf->
|
180
|
+
if (slcf->pairs == NULL
|
148
181
|
|| r->headers_out.content_length_n == 0
|
149
182
|
|| ngx_http_test_content_type(r, &slcf->types) == NULL)
|
150
183
|
{
|
@@ -156,19 +189,76 @@ ngx_http_sub_header_filter(ngx_http_request_t *r)
|
|
156
189
|
return NGX_ERROR;
|
157
190
|
}
|
158
191
|
|
159
|
-
|
192
|
+
if (slcf->dynamic == 0) {
|
193
|
+
ctx->tables = slcf->tables;
|
194
|
+
ctx->matches = slcf->matches;
|
195
|
+
|
196
|
+
} else {
|
197
|
+
pairs = slcf->pairs->elts;
|
198
|
+
n = slcf->pairs->nelts;
|
199
|
+
|
200
|
+
matches = ngx_pcalloc(r->pool, sizeof(ngx_http_sub_match_t) * n);
|
201
|
+
if (matches == NULL) {
|
202
|
+
return NGX_ERROR;
|
203
|
+
}
|
204
|
+
|
205
|
+
j = 0;
|
206
|
+
for (i = 0; i < n; i++) {
|
207
|
+
matches[j].value = &pairs[i].value;
|
208
|
+
|
209
|
+
if (pairs[i].match.lengths == NULL) {
|
210
|
+
matches[j].match = pairs[i].match.value;
|
211
|
+
j++;
|
212
|
+
continue;
|
213
|
+
}
|
214
|
+
|
215
|
+
m = &matches[j].match;
|
216
|
+
if (ngx_http_complex_value(r, &pairs[i].match, m) != NGX_OK) {
|
217
|
+
return NGX_ERROR;
|
218
|
+
}
|
219
|
+
|
220
|
+
if (m->len == 0) {
|
221
|
+
continue;
|
222
|
+
}
|
223
|
+
|
224
|
+
ngx_strlow(m->data, m->data, m->len);
|
225
|
+
j++;
|
226
|
+
}
|
227
|
+
|
228
|
+
if (j == 0) {
|
229
|
+
return ngx_http_next_header_filter(r);
|
230
|
+
}
|
231
|
+
|
232
|
+
ctx->matches = ngx_palloc(r->pool, sizeof(ngx_array_t));
|
233
|
+
if (ctx->matches == NULL) {
|
234
|
+
return NGX_ERROR;
|
235
|
+
}
|
236
|
+
|
237
|
+
ctx->matches->elts = matches;
|
238
|
+
ctx->matches->nelts = j;
|
239
|
+
|
240
|
+
ctx->tables = ngx_palloc(r->pool, sizeof(ngx_http_sub_tables_t));
|
241
|
+
if (ctx->tables == NULL) {
|
242
|
+
return NGX_ERROR;
|
243
|
+
}
|
244
|
+
|
245
|
+
ngx_http_sub_init_tables(ctx->tables, ctx->matches->elts,
|
246
|
+
ctx->matches->nelts);
|
247
|
+
}
|
248
|
+
|
249
|
+
ngx_http_set_ctx(r, ctx, ngx_http_sub_filter_module);
|
250
|
+
|
251
|
+
ctx->saved.data = ngx_pnalloc(r->pool, ctx->tables->max_match_len - 1);
|
160
252
|
if (ctx->saved.data == NULL) {
|
161
253
|
return NGX_ERROR;
|
162
254
|
}
|
163
255
|
|
164
|
-
ctx->looked.data = ngx_pnalloc(r->pool,
|
256
|
+
ctx->looked.data = ngx_pnalloc(r->pool, ctx->tables->max_match_len - 1);
|
165
257
|
if (ctx->looked.data == NULL) {
|
166
258
|
return NGX_ERROR;
|
167
259
|
}
|
168
260
|
|
169
|
-
|
170
|
-
|
171
|
-
ctx->match = slcf->match;
|
261
|
+
ctx->offset = ctx->tables->min_match_len - 1;
|
172
262
|
ctx->last_out = &ctx->out;
|
173
263
|
|
174
264
|
r->filter_need_in_memory = 1;
|
@@ -194,8 +284,10 @@ ngx_http_sub_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|
194
284
|
{
|
195
285
|
ngx_int_t rc;
|
196
286
|
ngx_buf_t *b;
|
287
|
+
ngx_str_t *sub;
|
197
288
|
ngx_chain_t *cl;
|
198
289
|
ngx_http_sub_ctx_t *ctx;
|
290
|
+
ngx_http_sub_match_t *match;
|
199
291
|
ngx_http_sub_loc_conf_t *slcf;
|
200
292
|
|
201
293
|
ctx = ngx_http_get_module_ctx(r, ngx_http_sub_filter_module);
|
@@ -242,22 +334,14 @@ ngx_http_sub_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|
242
334
|
ctx->pos = ctx->buf->pos;
|
243
335
|
}
|
244
336
|
|
245
|
-
if (ctx->state == sub_start_state) {
|
246
|
-
ctx->copy_start = ctx->pos;
|
247
|
-
ctx->copy_end = ctx->pos;
|
248
|
-
}
|
249
|
-
|
250
337
|
b = NULL;
|
251
338
|
|
252
339
|
while (ctx->pos < ctx->buf->last) {
|
253
340
|
|
254
|
-
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
255
|
-
"saved: \"%V\" state: %d", &ctx->saved, ctx->state);
|
256
|
-
|
257
341
|
rc = ngx_http_sub_parse(r, ctx);
|
258
342
|
|
259
343
|
ngx_log_debug4(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
260
|
-
"parse: %
|
344
|
+
"parse: %i, looked: \"%V\" %p-%p",
|
261
345
|
rc, &ctx->looked, ctx->copy_start, ctx->copy_end);
|
262
346
|
|
263
347
|
if (rc == NGX_ERROR) {
|
@@ -320,20 +404,6 @@ ngx_http_sub_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|
320
404
|
ctx->last_out = &cl->next;
|
321
405
|
}
|
322
406
|
|
323
|
-
if (ctx->state == sub_start_state) {
|
324
|
-
ctx->copy_start = ctx->pos;
|
325
|
-
ctx->copy_end = ctx->pos;
|
326
|
-
|
327
|
-
} else {
|
328
|
-
ctx->copy_start = NULL;
|
329
|
-
ctx->copy_end = NULL;
|
330
|
-
}
|
331
|
-
|
332
|
-
if (ctx->looked.len > (size_t) (ctx->pos - ctx->buf->pos)) {
|
333
|
-
ctx->saved.len = ctx->looked.len - (ctx->pos - ctx->buf->pos);
|
334
|
-
ngx_memcpy(ctx->saved.data, ctx->looked.data, ctx->saved.len);
|
335
|
-
}
|
336
|
-
|
337
407
|
if (rc == NGX_AGAIN) {
|
338
408
|
continue;
|
339
409
|
}
|
@@ -352,19 +422,30 @@ ngx_http_sub_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|
352
422
|
|
353
423
|
slcf = ngx_http_get_module_loc_conf(r, ngx_http_sub_filter_module);
|
354
424
|
|
355
|
-
if (ctx->sub
|
425
|
+
if (ctx->sub == NULL) {
|
426
|
+
ctx->sub = ngx_pcalloc(r->pool, sizeof(ngx_str_t)
|
427
|
+
* ctx->matches->nelts);
|
428
|
+
if (ctx->sub == NULL) {
|
429
|
+
return NGX_ERROR;
|
430
|
+
}
|
431
|
+
}
|
432
|
+
|
433
|
+
sub = &ctx->sub[ctx->index];
|
434
|
+
|
435
|
+
if (sub->data == NULL) {
|
436
|
+
match = ctx->matches->elts;
|
356
437
|
|
357
|
-
if (ngx_http_complex_value(r,
|
438
|
+
if (ngx_http_complex_value(r, match[ctx->index].value, sub)
|
358
439
|
!= NGX_OK)
|
359
440
|
{
|
360
441
|
return NGX_ERROR;
|
361
442
|
}
|
362
443
|
}
|
363
444
|
|
364
|
-
if (
|
445
|
+
if (sub->len) {
|
365
446
|
b->memory = 1;
|
366
|
-
b->pos =
|
367
|
-
b->last =
|
447
|
+
b->pos = sub->data;
|
448
|
+
b->last = sub->data + sub->len;
|
368
449
|
|
369
450
|
} else {
|
370
451
|
b->sync = 1;
|
@@ -373,7 +454,8 @@ ngx_http_sub_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|
373
454
|
*ctx->last_out = cl;
|
374
455
|
ctx->last_out = &cl->next;
|
375
456
|
|
376
|
-
ctx->
|
457
|
+
ctx->index = 0;
|
458
|
+
ctx->once = slcf->once && (++ctx->applied == ctx->matches->nelts);
|
377
459
|
|
378
460
|
continue;
|
379
461
|
}
|
@@ -428,9 +510,6 @@ ngx_http_sub_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|
428
510
|
}
|
429
511
|
|
430
512
|
ctx->buf = NULL;
|
431
|
-
|
432
|
-
ctx->saved.len = ctx->looked.len;
|
433
|
-
ngx_memcpy(ctx->saved.data, ctx->looked.data, ctx->looked.len);
|
434
513
|
}
|
435
514
|
|
436
515
|
if (ctx->out == NULL && ctx->busy == NULL) {
|
@@ -513,158 +592,142 @@ ngx_http_sub_output(ngx_http_request_t *r, ngx_http_sub_ctx_t *ctx)
|
|
513
592
|
static ngx_int_t
|
514
593
|
ngx_http_sub_parse(ngx_http_request_t *r, ngx_http_sub_ctx_t *ctx)
|
515
594
|
{
|
516
|
-
u_char
|
517
|
-
|
518
|
-
|
595
|
+
u_char *p, *last, *pat, *pat_end, c;
|
596
|
+
ngx_str_t *m;
|
597
|
+
ngx_int_t offset, start, next, end, len, rc;
|
598
|
+
ngx_uint_t shift, i, j;
|
599
|
+
ngx_http_sub_match_t *match;
|
600
|
+
ngx_http_sub_tables_t *tables;
|
601
|
+
ngx_http_sub_loc_conf_t *slcf;
|
519
602
|
|
520
|
-
|
521
|
-
|
522
|
-
ctx->copy_end = ctx->buf->last;
|
523
|
-
ctx->pos = ctx->buf->last;
|
524
|
-
ctx->looked.len = 0;
|
603
|
+
slcf = ngx_http_get_module_loc_conf(r, ngx_http_sub_filter_module);
|
604
|
+
tables = ctx->tables;
|
525
605
|
|
526
|
-
|
606
|
+
offset = ctx->offset;
|
607
|
+
end = ctx->buf->last - ctx->pos;
|
527
608
|
|
528
|
-
|
609
|
+
if (ctx->once) {
|
610
|
+
/* sets start and next to end */
|
611
|
+
offset = end + (ngx_int_t) tables->min_match_len - 1;
|
612
|
+
goto again;
|
529
613
|
}
|
530
614
|
|
531
|
-
|
532
|
-
looked = ctx->looked.len;
|
533
|
-
last = ctx->buf->last;
|
534
|
-
copy_end = ctx->copy_end;
|
615
|
+
while (offset < end) {
|
535
616
|
|
536
|
-
|
617
|
+
c = offset < 0 ? ctx->looked.data[ctx->looked.len + offset]
|
618
|
+
: ctx->pos[offset];
|
537
619
|
|
538
|
-
|
539
|
-
ch = ngx_tolower(ch);
|
620
|
+
c = ngx_tolower(c);
|
540
621
|
|
541
|
-
|
622
|
+
shift = tables->shift[c];
|
623
|
+
if (shift > 0) {
|
624
|
+
offset += shift;
|
625
|
+
continue;
|
626
|
+
}
|
542
627
|
|
543
|
-
|
628
|
+
/* a potential match */
|
544
629
|
|
545
|
-
|
630
|
+
start = offset - (ngx_int_t) tables->min_match_len + 1;
|
631
|
+
match = ctx->matches->elts;
|
546
632
|
|
547
|
-
|
548
|
-
|
633
|
+
i = ngx_max(tables->index[c], ctx->index);
|
634
|
+
j = tables->index[c + 1];
|
549
635
|
|
550
|
-
|
551
|
-
ctx->pos = p + 1;
|
552
|
-
ctx->copy_end = p;
|
636
|
+
while (i != j) {
|
553
637
|
|
554
|
-
|
555
|
-
|
638
|
+
if (slcf->once && ctx->sub && ctx->sub[i].data) {
|
639
|
+
goto next;
|
640
|
+
}
|
556
641
|
|
557
|
-
|
558
|
-
ctx->looked.data[0] = *p;
|
559
|
-
looked = 1;
|
560
|
-
state = sub_match_state;
|
642
|
+
m = &match[i].match;
|
561
643
|
|
562
|
-
|
563
|
-
|
644
|
+
pat = m->data;
|
645
|
+
pat_end = m->data + m->len;
|
564
646
|
|
565
|
-
|
566
|
-
|
567
|
-
}
|
647
|
+
if (start >= 0) {
|
648
|
+
p = ctx->pos + start;
|
568
649
|
|
569
|
-
|
570
|
-
|
571
|
-
|
650
|
+
} else {
|
651
|
+
last = ctx->looked.data + ctx->looked.len;
|
652
|
+
p = last + start;
|
572
653
|
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
654
|
+
while (p < last && pat < pat_end) {
|
655
|
+
if (ngx_tolower(*p) != *pat) {
|
656
|
+
goto next;
|
657
|
+
}
|
577
658
|
|
578
|
-
|
579
|
-
|
659
|
+
p++;
|
660
|
+
pat++;
|
661
|
+
}
|
662
|
+
|
663
|
+
p = ctx->pos;
|
580
664
|
}
|
581
665
|
|
582
|
-
|
666
|
+
while (p < ctx->buf->last && pat < pat_end) {
|
667
|
+
if (ngx_tolower(*p) != *pat) {
|
668
|
+
goto next;
|
669
|
+
}
|
583
670
|
|
584
|
-
|
671
|
+
p++;
|
672
|
+
pat++;
|
673
|
+
}
|
585
674
|
|
586
|
-
|
587
|
-
}
|
675
|
+
ctx->index = i;
|
588
676
|
|
589
|
-
|
677
|
+
if (pat != pat_end) {
|
678
|
+
/* partial match */
|
679
|
+
goto again;
|
680
|
+
}
|
590
681
|
|
591
|
-
|
592
|
-
|
593
|
-
|
682
|
+
ctx->offset = offset + (ngx_int_t) m->len;
|
683
|
+
next = start + (ngx_int_t) m->len;
|
684
|
+
end = ngx_max(next, 0);
|
685
|
+
rc = NGX_OK;
|
594
686
|
|
595
|
-
|
687
|
+
goto done;
|
596
688
|
|
597
|
-
|
598
|
-
ctx->pos = p + 1;
|
599
|
-
ctx->looked.len = 0;
|
600
|
-
ctx->saved.len = 0;
|
601
|
-
ctx->copy_end = copy_end;
|
689
|
+
next:
|
602
690
|
|
603
|
-
|
604
|
-
|
605
|
-
}
|
691
|
+
i++;
|
692
|
+
}
|
606
693
|
|
607
|
-
|
608
|
-
|
694
|
+
offset++;
|
695
|
+
ctx->index = 0;
|
696
|
+
}
|
609
697
|
|
610
|
-
|
611
|
-
/*
|
612
|
-
* check if there is another partial match in previously
|
613
|
-
* matched substring to catch cases like "aab" in "aaab"
|
614
|
-
*/
|
615
|
-
|
616
|
-
ctx->looked.data[looked] = *p;
|
617
|
-
looked++;
|
618
|
-
|
619
|
-
for (i = 1; i < looked; i++) {
|
620
|
-
if (ngx_strncasecmp(ctx->looked.data + i,
|
621
|
-
ctx->match.data, looked - i)
|
622
|
-
== 0)
|
623
|
-
{
|
624
|
-
break;
|
625
|
-
}
|
626
|
-
}
|
698
|
+
again:
|
627
699
|
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
700
|
+
ctx->offset = offset;
|
701
|
+
start = offset - (ngx_int_t) tables->min_match_len + 1;
|
702
|
+
next = start;
|
703
|
+
rc = NGX_AGAIN;
|
632
704
|
|
633
|
-
|
634
|
-
copy_end = p + 1 - (looked - i);
|
635
|
-
}
|
705
|
+
done:
|
636
706
|
|
637
|
-
|
638
|
-
looked = looked - i;
|
707
|
+
/* send [ - looked.len, start ] to client */
|
639
708
|
|
640
|
-
|
641
|
-
|
642
|
-
looked = 0;
|
643
|
-
state = sub_start_state;
|
644
|
-
}
|
709
|
+
ctx->saved.len = ctx->looked.len + ngx_min(start, 0);
|
710
|
+
ngx_memcpy(ctx->saved.data, ctx->looked.data, ctx->saved.len);
|
645
711
|
|
646
|
-
|
647
|
-
|
648
|
-
goto out;
|
649
|
-
}
|
650
|
-
}
|
651
|
-
}
|
712
|
+
ctx->copy_start = ctx->pos;
|
713
|
+
ctx->copy_end = ctx->pos + ngx_max(start, 0);
|
652
714
|
|
653
|
-
|
715
|
+
/* save [ next, end ] in looked */
|
654
716
|
|
655
|
-
|
717
|
+
len = ngx_min(next, 0);
|
718
|
+
p = ctx->looked.data;
|
719
|
+
p = ngx_movemem(p, p + ctx->looked.len + len, - len);
|
656
720
|
|
657
|
-
|
658
|
-
ctx->pos
|
659
|
-
ctx->looked.len = looked;
|
721
|
+
len = ngx_max(next, 0);
|
722
|
+
p = ngx_cpymem(p, ctx->pos + len, end - len);
|
723
|
+
ctx->looked.len = p - ctx->looked.data;
|
660
724
|
|
661
|
-
|
725
|
+
/* update position */
|
662
726
|
|
663
|
-
|
664
|
-
|
665
|
-
}
|
727
|
+
ctx->pos += end;
|
728
|
+
ctx->offset -= end;
|
666
729
|
|
667
|
-
return
|
730
|
+
return rc;
|
668
731
|
}
|
669
732
|
|
670
733
|
|
@@ -674,23 +737,60 @@ ngx_http_sub_filter(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|
674
737
|
ngx_http_sub_loc_conf_t *slcf = conf;
|
675
738
|
|
676
739
|
ngx_str_t *value;
|
740
|
+
ngx_http_sub_pair_t *pair;
|
677
741
|
ngx_http_compile_complex_value_t ccv;
|
678
742
|
|
679
|
-
|
680
|
-
|
743
|
+
value = cf->args->elts;
|
744
|
+
|
745
|
+
if (value[1].len == 0) {
|
746
|
+
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "empty search pattern");
|
747
|
+
return NGX_CONF_ERROR;
|
681
748
|
}
|
682
749
|
|
683
|
-
|
750
|
+
if (slcf->pairs == NULL) {
|
751
|
+
slcf->pairs = ngx_array_create(cf->pool, 1,
|
752
|
+
sizeof(ngx_http_sub_pair_t));
|
753
|
+
if (slcf->pairs == NULL) {
|
754
|
+
return NGX_CONF_ERROR;
|
755
|
+
}
|
756
|
+
}
|
757
|
+
|
758
|
+
if (slcf->pairs->nelts == 255) {
|
759
|
+
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
760
|
+
"number of search patterns exceeds 255");
|
761
|
+
return NGX_CONF_ERROR;
|
762
|
+
}
|
684
763
|
|
685
764
|
ngx_strlow(value[1].data, value[1].data, value[1].len);
|
686
765
|
|
687
|
-
|
766
|
+
pair = ngx_array_push(slcf->pairs);
|
767
|
+
if (pair == NULL) {
|
768
|
+
return NGX_CONF_ERROR;
|
769
|
+
}
|
770
|
+
|
771
|
+
ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t));
|
772
|
+
|
773
|
+
ccv.cf = cf;
|
774
|
+
ccv.value = &value[1];
|
775
|
+
ccv.complex_value = &pair->match;
|
776
|
+
|
777
|
+
if (ngx_http_compile_complex_value(&ccv) != NGX_OK) {
|
778
|
+
return NGX_CONF_ERROR;
|
779
|
+
}
|
780
|
+
|
781
|
+
if (ccv.complex_value->lengths != NULL) {
|
782
|
+
slcf->dynamic = 1;
|
783
|
+
|
784
|
+
} else {
|
785
|
+
ngx_strlow(pair->match.value.data, pair->match.value.data,
|
786
|
+
pair->match.value.len);
|
787
|
+
}
|
688
788
|
|
689
789
|
ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t));
|
690
790
|
|
691
791
|
ccv.cf = cf;
|
692
792
|
ccv.value = &value[2];
|
693
|
-
ccv.complex_value = &
|
793
|
+
ccv.complex_value = &pair->value;
|
694
794
|
|
695
795
|
if (ngx_http_compile_complex_value(&ccv) != NGX_OK) {
|
696
796
|
return NGX_CONF_ERROR;
|
@@ -713,9 +813,12 @@ ngx_http_sub_create_conf(ngx_conf_t *cf)
|
|
713
813
|
/*
|
714
814
|
* set by ngx_pcalloc():
|
715
815
|
*
|
716
|
-
* conf->
|
816
|
+
* conf->dynamic = 0;
|
817
|
+
* conf->pairs = NULL;
|
818
|
+
* conf->tables = NULL;
|
717
819
|
* conf->types = { NULL };
|
718
820
|
* conf->types_keys = NULL;
|
821
|
+
* conf->matches = NULL;
|
719
822
|
*/
|
720
823
|
|
721
824
|
slcf->once = NGX_CONF_UNSET;
|
@@ -728,17 +831,15 @@ ngx_http_sub_create_conf(ngx_conf_t *cf)
|
|
728
831
|
static char *
|
729
832
|
ngx_http_sub_merge_conf(ngx_conf_t *cf, void *parent, void *child)
|
730
833
|
{
|
731
|
-
|
732
|
-
|
834
|
+
ngx_uint_t i, n;
|
835
|
+
ngx_http_sub_pair_t *pairs;
|
836
|
+
ngx_http_sub_match_t *matches;
|
837
|
+
ngx_http_sub_loc_conf_t *prev = parent;
|
838
|
+
ngx_http_sub_loc_conf_t *conf = child;
|
733
839
|
|
734
840
|
ngx_conf_merge_value(conf->once, prev->once, 1);
|
735
|
-
ngx_conf_merge_str_value(conf->match, prev->match, "");
|
736
841
|
ngx_conf_merge_value(conf->last_modified, prev->last_modified, 0);
|
737
842
|
|
738
|
-
if (conf->value.value.data == NULL) {
|
739
|
-
conf->value = prev->value;
|
740
|
-
}
|
741
|
-
|
742
843
|
if (ngx_http_merge_types(cf, &conf->types_keys, &conf->types,
|
743
844
|
&prev->types_keys, &prev->types,
|
744
845
|
ngx_http_html_default_types)
|
@@ -747,10 +848,109 @@ ngx_http_sub_merge_conf(ngx_conf_t *cf, void *parent, void *child)
|
|
747
848
|
return NGX_CONF_ERROR;
|
748
849
|
}
|
749
850
|
|
851
|
+
if (conf->pairs == NULL) {
|
852
|
+
conf->dynamic = prev->dynamic;
|
853
|
+
conf->pairs = prev->pairs;
|
854
|
+
conf->matches = prev->matches;
|
855
|
+
conf->tables = prev->tables;
|
856
|
+
}
|
857
|
+
|
858
|
+
if (conf->pairs && conf->dynamic == 0 && conf->tables == NULL) {
|
859
|
+
pairs = conf->pairs->elts;
|
860
|
+
n = conf->pairs->nelts;
|
861
|
+
|
862
|
+
matches = ngx_palloc(cf->pool, sizeof(ngx_http_sub_match_t) * n);
|
863
|
+
if (matches == NULL) {
|
864
|
+
return NGX_CONF_ERROR;
|
865
|
+
}
|
866
|
+
|
867
|
+
for (i = 0; i < n; i++) {
|
868
|
+
matches[i].match = pairs[i].match.value;
|
869
|
+
matches[i].value = &pairs[i].value;
|
870
|
+
}
|
871
|
+
|
872
|
+
conf->matches = ngx_palloc(cf->pool, sizeof(ngx_array_t));
|
873
|
+
if (conf->matches == NULL) {
|
874
|
+
return NGX_CONF_ERROR;
|
875
|
+
}
|
876
|
+
|
877
|
+
conf->matches->elts = matches;
|
878
|
+
conf->matches->nelts = n;
|
879
|
+
|
880
|
+
conf->tables = ngx_palloc(cf->pool, sizeof(ngx_http_sub_tables_t));
|
881
|
+
if (conf->tables == NULL) {
|
882
|
+
return NGX_CONF_ERROR;
|
883
|
+
}
|
884
|
+
|
885
|
+
ngx_http_sub_init_tables(conf->tables, conf->matches->elts,
|
886
|
+
conf->matches->nelts);
|
887
|
+
}
|
888
|
+
|
750
889
|
return NGX_CONF_OK;
|
751
890
|
}
|
752
891
|
|
753
892
|
|
893
|
+
static void
|
894
|
+
ngx_http_sub_init_tables(ngx_http_sub_tables_t *tables,
|
895
|
+
ngx_http_sub_match_t *match, ngx_uint_t n)
|
896
|
+
{
|
897
|
+
u_char c;
|
898
|
+
ngx_uint_t i, j, min, max, ch;
|
899
|
+
|
900
|
+
min = match[0].match.len;
|
901
|
+
max = match[0].match.len;
|
902
|
+
|
903
|
+
for (i = 1; i < n; i++) {
|
904
|
+
min = ngx_min(min, match[i].match.len);
|
905
|
+
max = ngx_max(max, match[i].match.len);
|
906
|
+
}
|
907
|
+
|
908
|
+
tables->min_match_len = min;
|
909
|
+
tables->max_match_len = max;
|
910
|
+
|
911
|
+
ngx_http_sub_cmp_index = tables->min_match_len - 1;
|
912
|
+
ngx_sort(match, n, sizeof(ngx_http_sub_match_t), ngx_http_sub_cmp_matches);
|
913
|
+
|
914
|
+
min = ngx_min(min, 255);
|
915
|
+
ngx_memset(tables->shift, min, 256);
|
916
|
+
|
917
|
+
ch = 0;
|
918
|
+
|
919
|
+
for (i = 0; i < n; i++) {
|
920
|
+
|
921
|
+
for (j = 0; j < min; j++) {
|
922
|
+
c = match[i].match.data[tables->min_match_len - 1 - j];
|
923
|
+
tables->shift[c] = ngx_min(tables->shift[c], (u_char) j);
|
924
|
+
}
|
925
|
+
|
926
|
+
c = match[i].match.data[tables->min_match_len - 1];
|
927
|
+
while (ch <= c) {
|
928
|
+
tables->index[ch++] = (u_char) i;
|
929
|
+
}
|
930
|
+
}
|
931
|
+
|
932
|
+
while (ch < 257) {
|
933
|
+
tables->index[ch++] = (u_char) n;
|
934
|
+
}
|
935
|
+
}
|
936
|
+
|
937
|
+
|
938
|
+
static ngx_int_t
|
939
|
+
ngx_http_sub_cmp_matches(const void *one, const void *two)
|
940
|
+
{
|
941
|
+
ngx_int_t c1, c2;
|
942
|
+
ngx_http_sub_match_t *first, *second;
|
943
|
+
|
944
|
+
first = (ngx_http_sub_match_t *) one;
|
945
|
+
second = (ngx_http_sub_match_t *) two;
|
946
|
+
|
947
|
+
c1 = first->match.data[ngx_http_sub_cmp_index];
|
948
|
+
c2 = second->match.data[ngx_http_sub_cmp_index];
|
949
|
+
|
950
|
+
return c1 - c2;
|
951
|
+
}
|
952
|
+
|
953
|
+
|
754
954
|
static ngx_int_t
|
755
955
|
ngx_http_sub_filter_init(ngx_conf_t *cf)
|
756
956
|
{
|