aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/event/ngx_event_quic.c11
-rw-r--r--src/event/ngx_event_quic.h1
-rw-r--r--src/http/modules/ngx_http_quic_module.h5
-rw-r--r--src/http/modules/ngx_http_ssl_module.c35
-rw-r--r--src/http/v3/ngx_http_v3.h5
5 files changed, 43 insertions, 14 deletions
diff --git a/src/event/ngx_event_quic.c b/src/event/ngx_event_quic.c
index a7e474803..49ed8f7ba 100644
--- a/src/event/ngx_event_quic.c
+++ b/src/event/ngx_event_quic.c
@@ -5813,3 +5813,14 @@ ngx_quic_free_frame(ngx_connection_t *c, ngx_quic_frame_t *frame)
"quic free frame n:%ui", qc->nframes);
#endif
}
+
+
+uint32_t
+ngx_quic_version(ngx_connection_t *c)
+{
+ uint32_t version;
+
+ version = c->quic->version;
+
+ return (version & 0xff000000) == 0xff000000 ? version & 0xff : version;
+}
diff --git a/src/event/ngx_event_quic.h b/src/event/ngx_event_quic.h
index e8bf926a0..fc41e0ce6 100644
--- a/src/event/ngx_event_quic.h
+++ b/src/event/ngx_event_quic.h
@@ -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);
void ngx_quic_finalize_connection(ngx_connection_t *c, ngx_uint_t err,
const char *reason);
+uint32_t ngx_quic_version(ngx_connection_t *c);
/********************************* DEBUG *************************************/
diff --git a/src/http/modules/ngx_http_quic_module.h b/src/http/modules/ngx_http_quic_module.h
index e744eb197..bd4930f8a 100644
--- a/src/http/modules/ngx_http_quic_module.h
+++ b/src/http/modules/ngx_http_quic_module.h
@@ -14,9 +14,8 @@
#include <ngx_http.h>
-#define NGX_HTTP_QUIC_ALPN(s) NGX_HTTP_QUIC_ALPN_DRAFT(s)
-#define NGX_HTTP_QUIC_ALPN_DRAFT(s) "\x05hq-" #s
-#define NGX_HTTP_QUIC_ALPN_ADVERTISE NGX_HTTP_QUIC_ALPN(NGX_QUIC_DRAFT_VERSION)
+#define NGX_HTTP_QUIC_ALPN_ADVERTISE "\x02hq"
+#define NGX_HTTP_QUIC_ALPN_DRAFT_FMT "\x05hq-%02uD"
extern ngx_module_t ngx_http_quic_module;
diff --git a/src/http/modules/ngx_http_ssl_module.c b/src/http/modules/ngx_http_ssl_module.c
index a2db307f7..111de479b 100644
--- a/src/http/modules/ngx_http_ssl_module.c
+++ b/src/http/modules/ngx_http_ssl_module.c
@@ -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,
void *arg)
{
+#if (NGX_HTTP_QUIC)
+ const char *fmt;
+#endif
unsigned int srvlen;
unsigned char *srv;
#if (NGX_DEBUG)
@@ -452,16 +455,32 @@ ngx_http_ssl_alpn_select(ngx_ssl_conn_t *ssl_conn, const unsigned char **out,
} else
#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 (hc->addr_conf->quic) {
- srv = (unsigned char *) NGX_HTTP_QUIC_ALPN_ADVERTISE;
- srvlen = sizeof(NGX_HTTP_QUIC_ALPN_ADVERTISE) - 1;
+#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;
+ 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
#endif
{
diff --git a/src/http/v3/ngx_http_v3.h b/src/http/v3/ngx_http_v3.h
index aab27b3ac..c244ab861 100644
--- a/src/http/v3/ngx_http_v3.h
+++ b/src/http/v3/ngx_http_v3.h
@@ -15,9 +15,8 @@
#include <ngx_http_v3_parse.h>
-#define NGX_HTTP_V3_ALPN(s) NGX_HTTP_V3_ALPN_DRAFT(s)
-#define NGX_HTTP_V3_ALPN_DRAFT(s) "\x05h3-" #s
-#define NGX_HTTP_V3_ALPN_ADVERTISE NGX_HTTP_V3_ALPN(NGX_QUIC_DRAFT_VERSION)
+#define NGX_HTTP_V3_ALPN_ADVERTISE "\x02h3"
+#define NGX_HTTP_V3_ALPN_DRAFT_FMT "\x05h3-%02uD"
#define NGX_HTTP_V3_VARLEN_INT_LEN 4
#define NGX_HTTP_V3_PREFIX_INT_LEN 11