comparison src/event/ngx_event_quic.c @ 8557:2727d402e5a5 quic

QUIC: switched to using fixed-length server connection IDs.
author Vladimir Homutov <vl@nginx.com>
date Fri, 18 Sep 2020 15:53:37 +0300
parents b383120afca3
children 0f37b4ef3cd9
comparison
equal deleted inserted replaced
8556:b383120afca3 8557:2727d402e5a5
908 908
909 909
910 static ngx_int_t 910 static ngx_int_t
911 ngx_quic_new_dcid(ngx_connection_t *c, ngx_str_t *odcid) 911 ngx_quic_new_dcid(ngx_connection_t *c, ngx_str_t *odcid)
912 { 912 {
913 uint8_t len;
914 ngx_quic_connection_t *qc; 913 ngx_quic_connection_t *qc;
915 914
916 qc = c->quic; 915 qc = c->quic;
917 916
918 if (RAND_bytes(&len, sizeof(len)) != 1) { 917 qc->dcid.len = NGX_QUIC_SERVER_CID_LEN;
919 return NGX_ERROR; 918 qc->dcid.data = ngx_pnalloc(c->pool, NGX_QUIC_SERVER_CID_LEN);
920 }
921
922 len = len % 10 + 10;
923
924 qc->dcid.len = len;
925 qc->dcid.data = ngx_pnalloc(c->pool, len);
926 if (qc->dcid.data == NULL) { 919 if (qc->dcid.data == NULL) {
927 return NGX_ERROR; 920 return NGX_ERROR;
928 } 921 }
929 922
930 if (RAND_bytes(qc->dcid.data, len) != 1) { 923 if (RAND_bytes(qc->dcid.data, NGX_QUIC_SERVER_CID_LEN) != 1) {
931 return NGX_ERROR; 924 return NGX_ERROR;
932 } 925 }
933 926
934 #ifdef NGX_QUIC_DEBUG_PACKETS 927 #ifdef NGX_QUIC_DEBUG_PACKETS
935 ngx_quic_hexdump(c->log, "quic server CID", qc->dcid.data, qc->dcid.len); 928 ngx_quic_hexdump(c->log, "quic server CID", qc->dcid.data, qc->dcid.len);