mirror of
https://github.com/nginx/nginx.git
synced 2025-06-23 22:50:39 +08:00
QUIC: multiple versions support in ALPN.
Previously, a version based on NGX_QUIC_DRAFT_VERSION was always set. Now it is taken from the negotiated QUIC version that may differ.
This commit is contained in:
parent
7f43460387
commit
b19923f91b
@ -5813,3 +5813,14 @@ ngx_quic_free_frame(ngx_connection_t *c, ngx_quic_frame_t *frame)
|
|||||||
"quic free frame n:%ui", qc->nframes);
|
"quic free frame n:%ui", qc->nframes);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t
|
||||||
|
ngx_quic_version(ngx_connection_t *c)
|
||||||
|
{
|
||||||
|
uint32_t version;
|
||||||
|
|
||||||
|
version = c->quic->version;
|
||||||
|
|
||||||
|
return (version & 0xff000000) == 0xff000000 ? version & 0xff : version;
|
||||||
|
}
|
||||||
|
@ -122,6 +122,7 @@ void ngx_quic_run(ngx_connection_t *c, ngx_quic_conf_t *conf);
|
|||||||
ngx_connection_t *ngx_quic_open_stream(ngx_connection_t *c, ngx_uint_t bidi);
|
ngx_connection_t *ngx_quic_open_stream(ngx_connection_t *c, ngx_uint_t bidi);
|
||||||
void ngx_quic_finalize_connection(ngx_connection_t *c, ngx_uint_t err,
|
void ngx_quic_finalize_connection(ngx_connection_t *c, ngx_uint_t err,
|
||||||
const char *reason);
|
const char *reason);
|
||||||
|
uint32_t ngx_quic_version(ngx_connection_t *c);
|
||||||
|
|
||||||
|
|
||||||
/********************************* DEBUG *************************************/
|
/********************************* DEBUG *************************************/
|
||||||
|
@ -14,9 +14,8 @@
|
|||||||
#include <ngx_http.h>
|
#include <ngx_http.h>
|
||||||
|
|
||||||
|
|
||||||
#define NGX_HTTP_QUIC_ALPN(s) NGX_HTTP_QUIC_ALPN_DRAFT(s)
|
#define NGX_HTTP_QUIC_ALPN_ADVERTISE "\x02hq"
|
||||||
#define NGX_HTTP_QUIC_ALPN_DRAFT(s) "\x05hq-" #s
|
#define NGX_HTTP_QUIC_ALPN_DRAFT_FMT "\x05hq-%02uD"
|
||||||
#define NGX_HTTP_QUIC_ALPN_ADVERTISE NGX_HTTP_QUIC_ALPN(NGX_QUIC_DRAFT_VERSION)
|
|
||||||
|
|
||||||
|
|
||||||
extern ngx_module_t ngx_http_quic_module;
|
extern ngx_module_t ngx_http_quic_module;
|
||||||
|
@ -418,6 +418,9 @@ ngx_http_ssl_alpn_select(ngx_ssl_conn_t *ssl_conn, const unsigned char **out,
|
|||||||
unsigned char *outlen, const unsigned char *in, unsigned int inlen,
|
unsigned char *outlen, const unsigned char *in, unsigned int inlen,
|
||||||
void *arg)
|
void *arg)
|
||||||
{
|
{
|
||||||
|
#if (NGX_HTTP_QUIC)
|
||||||
|
const char *fmt;
|
||||||
|
#endif
|
||||||
unsigned int srvlen;
|
unsigned int srvlen;
|
||||||
unsigned char *srv;
|
unsigned char *srv;
|
||||||
#if (NGX_DEBUG)
|
#if (NGX_DEBUG)
|
||||||
@ -452,16 +455,32 @@ ngx_http_ssl_alpn_select(ngx_ssl_conn_t *ssl_conn, const unsigned char **out,
|
|||||||
|
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
#if (NGX_HTTP_V3)
|
|
||||||
if (hc->addr_conf->http3) {
|
|
||||||
srv = (unsigned char *) NGX_HTTP_V3_ALPN_ADVERTISE;
|
|
||||||
srvlen = sizeof(NGX_HTTP_V3_ALPN_ADVERTISE) - 1;
|
|
||||||
} else
|
|
||||||
#endif
|
|
||||||
#if (NGX_HTTP_QUIC)
|
#if (NGX_HTTP_QUIC)
|
||||||
if (hc->addr_conf->quic) {
|
if (hc->addr_conf->quic) {
|
||||||
srv = (unsigned char *) NGX_HTTP_QUIC_ALPN_ADVERTISE;
|
#if (NGX_HTTP_V3)
|
||||||
srvlen = sizeof(NGX_HTTP_QUIC_ALPN_ADVERTISE) - 1;
|
if (hc->addr_conf->http3) {
|
||||||
|
srv = (unsigned char *) NGX_HTTP_V3_ALPN_ADVERTISE;
|
||||||
|
srvlen = sizeof(NGX_HTTP_V3_ALPN_ADVERTISE) - 1;
|
||||||
|
fmt = NGX_HTTP_V3_ALPN_DRAFT_FMT;
|
||||||
|
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
srv = (unsigned char *) NGX_HTTP_QUIC_ALPN_ADVERTISE;
|
||||||
|
srvlen = sizeof(NGX_HTTP_QUIC_ALPN_ADVERTISE) - 1;
|
||||||
|
fmt = NGX_HTTP_QUIC_ALPN_DRAFT_FMT;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* QUIC draft */
|
||||||
|
|
||||||
|
if (ngx_quic_version(c) > 1) {
|
||||||
|
srv = ngx_pnalloc(c->pool, sizeof("\x05h3-xx") - 1);
|
||||||
|
if (srv == NULL) {
|
||||||
|
return SSL_TLSEXT_ERR_NOACK;
|
||||||
|
}
|
||||||
|
srvlen = ngx_sprintf(srv, fmt, ngx_quic_version(c)) - srv;
|
||||||
|
}
|
||||||
|
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
@ -15,9 +15,8 @@
|
|||||||
#include <ngx_http_v3_parse.h>
|
#include <ngx_http_v3_parse.h>
|
||||||
|
|
||||||
|
|
||||||
#define NGX_HTTP_V3_ALPN(s) NGX_HTTP_V3_ALPN_DRAFT(s)
|
#define NGX_HTTP_V3_ALPN_ADVERTISE "\x02h3"
|
||||||
#define NGX_HTTP_V3_ALPN_DRAFT(s) "\x05h3-" #s
|
#define NGX_HTTP_V3_ALPN_DRAFT_FMT "\x05h3-%02uD"
|
||||||
#define NGX_HTTP_V3_ALPN_ADVERTISE NGX_HTTP_V3_ALPN(NGX_QUIC_DRAFT_VERSION)
|
|
||||||
|
|
||||||
#define NGX_HTTP_V3_VARLEN_INT_LEN 4
|
#define NGX_HTTP_V3_VARLEN_INT_LEN 4
|
||||||
#define NGX_HTTP_V3_PREFIX_INT_LEN 11
|
#define NGX_HTTP_V3_PREFIX_INT_LEN 11
|
||||||
|
Loading…
Reference in New Issue
Block a user