summaryrefslogtreecommitdiffhomepage
path: root/src (follow)
AgeCommit message (Collapse)AuthorFilesLines
2022-10-12PROXY protocol v2 TLV variables.Roman Arutyunyan4-2/+265
The variables have prefix $proxy_protocol_tlv_ and are accessible by name and by type. Examples are: $proxy_protocol_tlv_0x01, $proxy_protocol_tlv_alpn.
2022-10-10Log only the first line of user input on PROXY protocol v1 error.Roman Arutyunyan1-1/+7
Previously, all received user input was logged. If a multi-line text was received from client and logged, it could reduce log readability and also make it harder to parse nginx log by scripts. The change brings to PROXY protocol the same behavior that exists for HTTP request line in ngx_http_log_error_handler().
2022-09-08SSL: silenced GCC warnings when building with BoringSSL.Sergey Kandaurov1-1/+1
BoringSSL uses macro stub for SSL_CTX_set_ecdh_auto that expands to 1, which triggers -Wunused-value "statement with no effect" warnings.
2022-09-07Win32: fixed build on Windows with OpenSSL 3.0.x (ticket #2379).Maxim Dounin1-3/+3
SSL_sendfile() expects integer file descriptor as an argument, but nginx uses OS file handles (HANDLE) to work with files on Windows, and passing HANDLE instead of an integer correctly results in build failure. Since SSL_sendfile() is not expected to work on Windows anyway, the code is now disabled on Windows with appropriate compile-time checks.
2022-09-07Win32: disabled C4306 warnings with MSVC.Maxim Dounin1-0/+3
Multiple C4306 warnings (conversion from 'type1' to 'type2' of greater size) appear during 64-bit compilation with MSVC 2010 (and older) due to extensively used constructs like "(void *) -1", so they were disabled. In newer MSVC versions C4306 warnings were replaced with C4312 ones, and these are not generated for such trivial type casts.
2022-09-07Win32: removed misleading comment about warnings being disabled.Maxim Dounin1-2/+0
Warnings being disabled are not only from the "-W4" level since e4590dfd97ff.
2022-09-07SSL: fixed incorrect usage of #if instead of #ifdef.Maxim Dounin1-1/+1
In 2014ed60f17f, "#if SSL_CTRL_SET_ECDH_AUTO" test was incorrectly used instead of "#ifdef SSL_CTRL_SET_ECDH_AUTO". There is no practical difference, since SSL_CTRL_SET_ECDH_AUTO evaluates to a non-zero numeric value when defined, but anyway it's better to correctly test if the value is defined.
2022-09-07Events: fixed style and wrong error handling in the iocp module.Maxim Dounin1-4/+3
2022-08-22HTTP/3: renamed functions.Roman Arutyunyan3-6/+6
ngx_http_v3_init() is renamed ngx_http_v3_init_stream(). ngx_http_v3_reset_connection() is renamed to ngx_http_v3_reset_stream().
2022-11-30QUIC: removed cancelable flag from QUIC and HTTP/3 events.Roman Arutyunyan2-5/+0
All these events are created in context of a client connection and are deleted when the connection is closed. Setting ev->cancelable could trigger premature connection closure and a socket leak alert.
2022-10-19QUIC: idle mode for main connection.Roman Arutyunyan5-4/+57
Now main QUIC connection for HTTP/3 always has c->idle flag set. This allows the connection to receive worker shutdown notification. It is passed to application level via a new conf->shutdown() callback. The HTTP/3 shutdown callback sends GOAWAY to client and gracefully shuts down the QUIC connection.
2022-10-19HTTP/3: unified hq code with regular HTTP/3 code.Roman Arutyunyan4-100/+62
The change removes hq-specific request handler. Now hq requests are handled by the HTTP/3 request handler.
2022-09-07QUIC: do not send MAX_STREAMS in shutdown state.Roman Arutyunyan1-8/+9
No more streams are expected from client.
2022-08-22QUIC: defer stream removal until all its data is acked.Roman Arutyunyan3-23/+64
Previously, stream was kept alive until all its data is sent. This resulted in disabling retransmission of final part of stream when QUIC connection was closed right after closing stream connection.
2022-11-29QUIC: reusable mode for main connection.Roman Arutyunyan4-54/+110
The connection is automatically switched to this mode by transport layer when there are no non-cancelable streams. Currently, cancelable streams are HTTP/3 encoder/decoder/control streams.
2022-09-07QUIC: post close event for connection close.Roman Arutyunyan2-23/+26
Previously, close event was used only for close timeout, while read event was used for posting connection close.
2022-08-22QUIC: made ngx_quic_finalize_connecion() more graceful.Roman Arutyunyan1-18/+14
Previously, ngx_quic_finalize_connection() closed the connection with NGX_ERROR code, which resulted in immediate connection closure. Now the code is NGX_OK, which provides a more graceful shutdown with a timeout.
2022-09-07QUIC: treat qc->error == -1 as a missing error.Roman Arutyunyan1-3/+3
Previously, zero was used for this purpose. However, NGX_QUIC_ERR_NO_ERROR is zero too. As a result, NGX_QUIC_ERR_NO_ERROR was changed to NGX_QUIC_ERR_INTERNAL_ERROR when closing a QUIC connection.
2022-11-25QUIC: fixed computation of nonce with packet numbers beyond 2^32.Sergey Kandaurov1-4/+8
Prodded by Yu Zhu.
2022-11-25HTTP/3: fixed build without NGX_PCRE (broken by 0f5fc7a320db).Jiuzhou Cui1-0/+2
2022-11-23QUIC: fixed triggering stream read event (ticket #2409).Roman Arutyunyan1-1/+1
If a client packet carrying a stream data frame is not acked due to packet loss, the stream data is retransmitted later by client. It's also possible that the retransmitted range is bigger than before due to more stream data being available by then. If the original data was read out by the application, there would be no read event triggered by the retransmitted frame, even though it contains new data.
2022-11-22QUIC: fixed C4334 MSVC warning about 32 to 64 bits conversion.Sergey Kandaurov1-1/+1
2022-11-22QUIC: plug MSVC warning about potentially uninitialized variable.Sergey Kandaurov1-0/+4
2022-11-22Added shutdown macros for win32 required for QUIC.Sergey Kandaurov1-0/+2
2022-11-22QUIC: fixed C4389 MSVC warning about signed/unsigned mismatch.Sergey Kandaurov1-1/+2
2022-11-22QUIC: avoid using C99 designated initializers.Sergey Kandaurov2-24/+23
They are not supported by MSVC till 2012. SSL_QUIC_METHOD initialization is moved to run-time to preserve portability among SSL library implementations, which allows to reduce its visibility. Note using of a static storage to keep SSL_set_quic_method() reference valid.
2022-11-22QUIC: moved variable declaration to fix build with MSVC 2010.Sergey Kandaurov1-36/+32
Previously, ngx_quic_hkdf_t variables used declaration with assignment in the middle of a function, which is not supported by MSVC 2010. Fixing this also required to rewrite the ngx_quic_hkdf_set macro and to switch to an explicit array size.
2022-11-22QUIC: fixed C4706 warnings with MSVC 2010.Sergey Kandaurov1-16/+44
The fix is to avoid assignments within conditional expression.
2022-11-22HTTP/3: fixed server_name regex captures (ticket #2407).Sergey Kandaurov1-0/+1
Previously, HTTP/3 stream connection didn't inherit the servername regex from the main QUIC connection saved when processing SNI and using regular expressions in server names. As a result, it didn't execute to set regex captures when choosing the virtual server while parsing HTTP/3 headers.
2022-11-01Set default listen socket type in http.Roman Arutyunyan1-0/+1
The type field was added in 7999d3fbb765 at early stages of QUIC implementation and was not initialized for default listen. Missing initialization resulted in default listen socket creation error.
2022-10-20Merged with the default branch.Sergey Kandaurov13-147/+785
2022-10-20QUIC: removed compatibility with older BoringSSL API.Sergey Kandaurov1-8/+4
SSL_CIPHER_get_protocol_id() appeared in BoringSSL somewhere between BORINGSSL_API_VERSION 12 and 13 for compatibility with OpenSSL 1.1.1. It was adopted without a proper macro test, which remained unnoticed. This justifies that such old BoringSSL API isn't widely used and its support can be dropped. While here, removed SSL_set_quic_use_legacy_codepoint() that became useless after the default was flipped in BoringSSL over a year ago.
2022-10-20QUIC: support for setting QUIC methods with LibreSSL.Sergey Kandaurov1-9/+9
Setting QUIC methods is converted to use C99 designated initializers for simplicity, as LibreSSL 3.6.0 has different SSL_QUIC_METHOD layout. Additionally, only set_read_secret/set_write_secret callbacks are set. Although they are preferred in LibreSSL over set_encryption_secrets, better be on a safe side as LibreSSL has unexpectedly incompatible set_encryption_secrets calling convention expressed in passing read and write secrets split in separate calls, unlike this is documented in old BoringSSL sources. To avoid introducing further changes for the old API, it is simply disabled.
2022-10-20QUIC: using SSL_set_quic_early_data_enabled() only with QuicTLS.Sergey Kandaurov1-1/+1
This function is present in QuicTLS only. After SSL_READ_EARLY_DATA_SUCCESS became visible in LibreSSL together with experimental QUIC API, this required to revise the conditional compilation test to use more narrow macros.
2022-10-20QUIC: using native TLSv1.3 cipher suite constants.Sergey Kandaurov1-8/+11
After BoringSSL aligned[1] with OpenSSL on TLS1_3_CK_* macros, and LibreSSL uses OpenSSL naming, our own variants can be dropped now. Compatibility is preserved with libraries that lack these macros. Additionally, transition to SSL_CIPHER_get_id() fixes build error with LibreSSL that doesn't implement SSL_CIPHER_get_protocol_id(). [1] https://boringssl.googlesource.com/boringssl/+/dfddbc4ded
2022-09-30QUIC: "info" logging level on insufficient client connection ids.Sergey Kandaurov1-1/+1
Apparently, this error is reported on NAT rebinding if client didn't previously send NEW_CONNECTION_ID to supply additional connection ids.
2022-08-09SSL: logging level of "bad record type" errors.Murilo Andrade1-0/+3
The SSL_R_BAD_RECORD_TYPE ("bad record type") errors are reported by OpenSSL 1.1.1 or newer when using TLSv1.3 if the client sends a record with unknown or unexpected type. These errors are now logged at the "info" level.
2022-08-30Version bump.Maxim Dounin1-2/+2
2022-08-03HTTP/3: skip empty request body buffers (ticket #2374).Roman Arutyunyan1-7/+9
When client DATA frame header and its content come in different QUIC packets, it may happen that only the header is processed by the first ngx_http_v3_request_body_filter() call. In this case an empty request body buffer is added to r->request_body->bufs, which is later reused in a subsequent ngx_http_v3_request_body_filter() call without being removed from the body chain. As a result, rb->request_body->bufs ends up with two copies of the same buffer. The fix is to avoid adding empty request body buffers to r->request_body->bufs.
2022-07-15Events: fixed EPOLLRDHUP with FIONREAD (ticket #2367).Maxim Dounin1-0/+2
When reading exactly rev->available bytes, rev->available might become 0 after FIONREAD usage introduction in efd71d49bde0. On the next call of ngx_readv_chain() on systems with EPOLLRDHUP this resulted in return without any actions, that is, with rev->ready set, and this in turn resulted in no timers set in event pipe, leading to socket leaks. Fix is to reset rev->ready in ngx_readv_chain() when returning due to rev->available being 0 with EPOLLRDHUP, much like it is already done in ngx_unix_recv(). This ensures that if rev->available will become 0, on systems with EPOLLRDHUP support appropriate EPOLLRDHUP-specific handling will happen on the next ngx_readv_chain() call. While here, also synced ngx_readv_chain() to match ngx_unix_recv() and reset rev->ready when returning due to rev->available being 0 with kqueue. This is mostly cosmetic change, as rev->ready is anyway reset when rev->available is set to 0.
2022-07-15Range filter: clearing of pre-existing Content-Range headers.Maxim Dounin1-0/+13
Some servers might emit Content-Range header on 200 responses, and this does not seem to contradict RFC 9110: as per RFC 9110, the Content-Range header has no meaning for status codes other than 206 and 416. Previously this resulted in duplicate Content-Range headers in nginx responses handled by the range filter. Fix is to clear pre-existing headers.
2022-07-14Resolver: fixed memory leak for the "ipv4=off" case.Sergey Kandaurov1-4/+1
This change partially reverts 2a77754cd9fe to properly free rn->query. Found by Coverity (CID 1507244).
2022-07-12The "ipv4=" parameter of the "resolver" directive.Ruslan Ermilov2-15/+54
When set to "off", only IPv6 addresses will be resolved, and no A queries are ever sent (ticket #2196).
2022-07-12SSL: logging levels of various errors added in OpenSSL 1.1.1.Maxim Dounin1-0/+12
Starting with OpenSSL 1.1.1, various additional errors can be reported by OpenSSL in case of client-related issues, most notably during TLSv1.3 handshakes. In particular, SSL_R_BAD_KEY_SHARE ("bad key share"), SSL_R_BAD_EXTENSION ("bad extension"), SSL_R_BAD_CIPHER ("bad cipher"), SSL_R_BAD_ECPOINT ("bad ecpoint"). These are now logged at the "info" level.
2022-06-29Upstream: optimized use of SSL contexts (ticket #1234).Maxim Dounin4-27/+235
To ensure optimal use of memory, SSL contexts for proxying are now inherited from previous levels as long as relevant proxy_ssl_* directives are not redefined. Further, when no proxy_ssl_* directives are redefined in a server block, we now preserve plcf->upstream.ssl in the "http" section configuration to inherit it to all servers. Similar changes made in uwsgi, grpc, and stream proxy.
2022-06-29Version bump.Maxim Dounin1-2/+2
2022-06-14Perl: removed unused variables, forgotten in ef6a3a99a81a.Sergey Kandaurov1-2/+1
2022-06-01Resolver: make TCP write timer event cancelable.Aleksei Bavshin1-0/+1
Similar to 70e65bf8dfd7, the change is made to ensure that the ability to cancel resolver tasks is fully controlled by the caller. As mentioned in the referenced commit, it is safe to make this timer cancelable because resolve tasks can have their own timeouts that are not cancelable. The scenario where this may become a problem is a periodic background resolve task (not tied to a specific request or a client connection), which receives a response with short TTL, large enough to warrant fallback to a TCP query. With each event loop wakeup, we either have a previously set write timer instance or schedule a new one. The non-cancelable write timer can delay or block graceful shutdown of a worker even if the ngx_resolver_ctx_t->cancelable flag is set by the API user, and there are no other tasks or connections. We use the resolver API in this way to maintain the list of upstream server addresses specified with the 'resolve' parameter, and there could be third-party modules implementing similar logic.
2022-05-31QUIC: avoided pool usage in token calculation.Vladimir Homutov4-20/+32
2022-07-27QUIC: removed ngx_quic_keys_new().Vladimir Homutov4-51/+44
The ngx_quic_keys_t structure is now exposed.