]> git.kaiwu.me - nginx.git/commitdiff
QUIC: switched to using fixed-length server connection IDs.
authorVladimir Homutov <vl@nginx.com>
Fri, 18 Sep 2020 12:53:37 +0000 (15:53 +0300)
committerVladimir Homutov <vl@nginx.com>
Fri, 18 Sep 2020 12:53:37 +0000 (15:53 +0300)
src/event/ngx_event_quic.c
src/event/ngx_event_quic.h

index d0e8f383dc2318e4d715e7dcb163346ac5ff7d97..f8e449517c17e544eef8f4a5f1726a92e7bff110 100644 (file)
@@ -910,24 +910,17 @@ ngx_quic_negotiate_version(ngx_connection_t *c, ngx_quic_header_t *inpkt)
 static ngx_int_t
 ngx_quic_new_dcid(ngx_connection_t *c, ngx_str_t *odcid)
 {
-    uint8_t                 len;
     ngx_quic_connection_t  *qc;
 
     qc = c->quic;
 
-    if (RAND_bytes(&len, sizeof(len)) != 1) {
-        return NGX_ERROR;
-    }
-
-    len = len % 10 + 10;
-
-    qc->dcid.len = len;
-    qc->dcid.data = ngx_pnalloc(c->pool, len);
+    qc->dcid.len = NGX_QUIC_SERVER_CID_LEN;
+    qc->dcid.data = ngx_pnalloc(c->pool, NGX_QUIC_SERVER_CID_LEN);
     if (qc->dcid.data == NULL) {
         return NGX_ERROR;
     }
 
-    if (RAND_bytes(qc->dcid.data, len) != 1) {
+    if (RAND_bytes(qc->dcid.data, NGX_QUIC_SERVER_CID_LEN) != 1) {
         return NGX_ERROR;
     }
 
index 2399860af2cd51b74b4deb1878598978bc4c9890..ef3a15a73b00da838dfb224e00f5cfcd1b4956d8 100644 (file)
@@ -54,6 +54,8 @@
 
 #define NGX_QUIC_STREAM_BUFSIZE              65536
 
+#define NGX_QUIC_SERVER_CID_LEN              20
+
 
 typedef struct {
     /* configurable */