comparison src/http/modules/ngx_http_ssl_module.c @ 8626:e0947c952d43 quic

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.
author Sergey Kandaurov <pluknet@nginx.com>
date Tue, 10 Nov 2020 00:32:56 +0300
parents 71b7453fb11f
children 5b51d8405378
comparison
equal deleted inserted replaced
8625:4416b7ab0a27 8626:e0947c952d43
416 static int 416 static int
417 ngx_http_ssl_alpn_select(ngx_ssl_conn_t *ssl_conn, const unsigned char **out, 417 ngx_http_ssl_alpn_select(ngx_ssl_conn_t *ssl_conn, const unsigned char **out,
418 unsigned char *outlen, const unsigned char *in, unsigned int inlen, 418 unsigned char *outlen, const unsigned char *in, unsigned int inlen,
419 void *arg) 419 void *arg)
420 { 420 {
421 #if (NGX_HTTP_QUIC)
422 const char *fmt;
423 #endif
421 unsigned int srvlen; 424 unsigned int srvlen;
422 unsigned char *srv; 425 unsigned char *srv;
423 #if (NGX_DEBUG) 426 #if (NGX_DEBUG)
424 unsigned int i; 427 unsigned int i;
425 #endif 428 #endif
450 (unsigned char *) NGX_HTTP_V2_ALPN_ADVERTISE NGX_HTTP_NPN_ADVERTISE; 453 (unsigned char *) NGX_HTTP_V2_ALPN_ADVERTISE NGX_HTTP_NPN_ADVERTISE;
451 srvlen = sizeof(NGX_HTTP_V2_ALPN_ADVERTISE NGX_HTTP_NPN_ADVERTISE) - 1; 454 srvlen = sizeof(NGX_HTTP_V2_ALPN_ADVERTISE NGX_HTTP_NPN_ADVERTISE) - 1;
452 455
453 } else 456 } else
454 #endif 457 #endif
455 #if (NGX_HTTP_V3)
456 if (hc->addr_conf->http3) {
457 srv = (unsigned char *) NGX_HTTP_V3_ALPN_ADVERTISE;
458 srvlen = sizeof(NGX_HTTP_V3_ALPN_ADVERTISE) - 1;
459 } else
460 #endif
461 #if (NGX_HTTP_QUIC) 458 #if (NGX_HTTP_QUIC)
462 if (hc->addr_conf->quic) { 459 if (hc->addr_conf->quic) {
463 srv = (unsigned char *) NGX_HTTP_QUIC_ALPN_ADVERTISE; 460 #if (NGX_HTTP_V3)
464 srvlen = sizeof(NGX_HTTP_QUIC_ALPN_ADVERTISE) - 1; 461 if (hc->addr_conf->http3) {
462 srv = (unsigned char *) NGX_HTTP_V3_ALPN_ADVERTISE;
463 srvlen = sizeof(NGX_HTTP_V3_ALPN_ADVERTISE) - 1;
464 fmt = NGX_HTTP_V3_ALPN_DRAFT_FMT;
465
466 } else
467 #endif
468 {
469 srv = (unsigned char *) NGX_HTTP_QUIC_ALPN_ADVERTISE;
470 srvlen = sizeof(NGX_HTTP_QUIC_ALPN_ADVERTISE) - 1;
471 fmt = NGX_HTTP_QUIC_ALPN_DRAFT_FMT;
472 }
473
474 /* QUIC draft */
475
476 if (ngx_quic_version(c) > 1) {
477 srv = ngx_pnalloc(c->pool, sizeof("\x05h3-xx") - 1);
478 if (srv == NULL) {
479 return SSL_TLSEXT_ERR_NOACK;
480 }
481 srvlen = ngx_sprintf(srv, fmt, ngx_quic_version(c)) - srv;
482 }
483
465 } else 484 } else
466 #endif 485 #endif
467 { 486 {
468 srv = (unsigned char *) NGX_HTTP_NPN_ADVERTISE; 487 srv = (unsigned char *) NGX_HTTP_NPN_ADVERTISE;
469 srvlen = sizeof(NGX_HTTP_NPN_ADVERTISE) - 1; 488 srvlen = sizeof(NGX_HTTP_NPN_ADVERTISE) - 1;