rwebtransport 0.2.2 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cargo.lock +523 -140
- package/Cargo.toml +5 -5
- package/README.md +8 -4
- package/crates/echo-server/src/bin/gen-test-cert.rs +1 -1
- package/crates/native/Cargo.toml +2 -0
- package/crates/native/src/config.rs +69 -8
- package/crates/native/src/driver.rs +253 -90
- package/crates/native/src/lib.rs +80 -57
- package/crates/native/src/parser_memory.rs +203 -0
- package/crates/native/src/server.rs +215 -183
- package/crates/native/src/session.rs +1341 -243
- package/crates/native/src/test_support.rs +119 -0
- package/crates/wtcore/Cargo.toml +1 -0
- package/crates/wtcore/src/h3.rs +250 -46
- package/dist/index.js +218 -75
- package/dist/index.js.map +7 -1
- package/dist/index.mjs +214 -69
- package/dist/index.mjs.map +7 -1
- package/dist/native.d.ts +10 -4
- package/dist/server.d.ts +1 -0
- package/package.json +84 -78
- package/prebuilds/darwin-arm64/rwebtransport.node +0 -0
- package/prebuilds/linux-arm64/rwebtransport.node +0 -0
- package/prebuilds/linux-x64/rwebtransport.node +0 -0
- package/prebuilds/win32-x64/rwebtransport.node +0 -0
- package/scripts/build-linux-prebuilt.sh +46 -0
- package/scripts/build-ts.js +41 -0
- package/scripts/build.js +10 -3
- package/vendor/quiche/AGENTS.md +10 -0
- package/vendor/quiche/Cargo.lock +239 -248
- package/vendor/quiche/Cargo.toml +23 -10
- package/vendor/quiche/examples/Makefile +4 -4
- package/vendor/quiche/examples/client.rs +10 -28
- package/vendor/quiche/examples/http3-client.rs +20 -34
- package/vendor/quiche/examples/http3-server.rs +47 -78
- package/vendor/quiche/examples/server.rs +19 -49
- package/vendor/quiche/include/quiche.h +35 -4
- package/vendor/quiche/src/build.rs +17 -0
- package/vendor/quiche/src/cid.rs +129 -61
- package/vendor/quiche/src/crypto/boringssl.rs +98 -86
- package/vendor/quiche/src/crypto/mod.rs +64 -77
- package/vendor/quiche/src/dgram.rs +2 -3
- package/vendor/quiche/src/error.rs +22 -20
- package/vendor/quiche/src/ffi.rs +558 -280
- package/vendor/quiche/src/flowcontrol.rs +0 -7
- package/vendor/quiche/src/frame.rs +134 -135
- package/vendor/quiche/src/h3/ffi.rs +73 -60
- package/vendor/quiche/src/h3/frame.rs +70 -90
- package/vendor/quiche/src/h3/mod.rs +1024 -593
- package/vendor/quiche/src/h3/qpack/decoder.rs +248 -34
- package/vendor/quiche/src/h3/qpack/dynamic_table.rs +859 -0
- package/vendor/quiche/src/h3/qpack/encoder.rs +14 -17
- package/vendor/quiche/src/h3/qpack/mod.rs +48 -0
- package/vendor/quiche/src/h3/qpack/static_table.rs +86 -73
- package/vendor/quiche/src/h3/stream.rs +1009 -194
- package/vendor/quiche/src/lib.rs +1361 -1195
- package/vendor/quiche/src/minmax.rs +2 -6
- package/vendor/quiche/src/packet.rs +420 -552
- package/vendor/quiche/src/path.rs +202 -72
- package/vendor/quiche/src/pmtud.rs +18 -16
- package/vendor/quiche/src/ranges.rs +184 -82
- package/vendor/quiche/src/recovery/AGENTS.md +5 -2
- package/vendor/quiche/src/recovery/bandwidth.rs +59 -40
- package/vendor/quiche/src/recovery/bytes_in_flight.rs +2 -2
- package/vendor/quiche/src/recovery/congestion/cubic.rs +38 -47
- package/vendor/quiche/src/recovery/congestion/delivery_rate.rs +54 -60
- package/vendor/quiche/src/recovery/congestion/hystart.rs +6 -10
- package/vendor/quiche/src/recovery/congestion/mod.rs +110 -42
- package/vendor/quiche/src/recovery/congestion/prr.rs +4 -1
- package/vendor/quiche/src/recovery/congestion/recovery.rs +91 -95
- package/vendor/quiche/src/recovery/congestion/reno.rs +17 -12
- package/vendor/quiche/src/recovery/congestion/test_sender.rs +8 -27
- package/vendor/quiche/src/recovery/gcongestion/bbr/bandwidth_sampler.rs +159 -247
- package/vendor/quiche/src/recovery/gcongestion/bbr/windowed_filter.rs +9 -14
- package/vendor/quiche/src/recovery/gcongestion/bbr2/drain.rs +18 -15
- package/vendor/quiche/src/recovery/gcongestion/bbr2/mode.rs +43 -28
- package/vendor/quiche/src/recovery/gcongestion/bbr2/network_model.rs +349 -76
- package/vendor/quiche/src/recovery/gcongestion/bbr2/probe_bw.rs +147 -195
- package/vendor/quiche/src/recovery/gcongestion/bbr2/probe_rtt.rs +29 -27
- package/vendor/quiche/src/recovery/gcongestion/bbr2/rtt_jump_detector/global_min.rs +180 -0
- package/vendor/quiche/src/recovery/gcongestion/bbr2/rtt_jump_detector/global_min_tests.rs +221 -0
- package/vendor/quiche/src/recovery/gcongestion/bbr2/rtt_jump_detector/hmm.rs +395 -0
- package/vendor/quiche/src/recovery/gcongestion/bbr2/rtt_jump_detector/hmm_tests.rs +473 -0
- package/vendor/quiche/src/recovery/gcongestion/bbr2/rtt_jump_detector/mod.rs +175 -0
- package/vendor/quiche/src/recovery/gcongestion/bbr2/startup.rs +33 -26
- package/vendor/quiche/src/recovery/gcongestion/bbr2.rs +107 -60
- package/vendor/quiche/src/recovery/gcongestion/mod.rs +64 -11
- package/vendor/quiche/src/recovery/gcongestion/pacer.rs +34 -25
- package/vendor/quiche/src/recovery/gcongestion/recovery.rs +81 -86
- package/vendor/quiche/src/recovery/mod.rs +414 -173
- package/vendor/quiche/src/recovery/rtt.rs +8 -5
- package/vendor/quiche/src/stream/mod.rs +864 -133
- package/vendor/quiche/src/stream/recv_buf.rs +476 -172
- package/vendor/quiche/src/stream/send_buf.rs +343 -81
- package/vendor/quiche/src/test_utils.rs +78 -64
- package/vendor/quiche/src/tests.rs +2559 -1335
- package/vendor/quiche/src/tls/boringssl.rs +60 -63
- package/vendor/quiche/src/tls/mod.rs +146 -193
- package/vendor/quiche/src/transport_params.rs +87 -103
|
@@ -44,7 +44,6 @@ use qlog::events::quic::StreamType;
|
|
|
44
44
|
|
|
45
45
|
pub const MAX_CRYPTO_OVERHEAD: usize = 8;
|
|
46
46
|
pub const MAX_DGRAM_OVERHEAD: usize = 2;
|
|
47
|
-
pub const MAX_STREAM_OVERHEAD: usize = 12;
|
|
48
47
|
pub const MAX_STREAM_SIZE: u64 = 1 << 62;
|
|
49
48
|
|
|
50
49
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
|
@@ -79,6 +78,7 @@ pub enum Frame {
|
|
|
79
78
|
stream_id: u64,
|
|
80
79
|
error_code: u64,
|
|
81
80
|
final_size: u64,
|
|
81
|
+
reliable_size: Option<u64>,
|
|
82
82
|
},
|
|
83
83
|
|
|
84
84
|
StopSending {
|
|
@@ -187,9 +187,7 @@ pub enum Frame {
|
|
|
187
187
|
}
|
|
188
188
|
|
|
189
189
|
impl Frame {
|
|
190
|
-
pub fn from_bytes(
|
|
191
|
-
b: &mut octets::Octets, pkt: packet::Type,
|
|
192
|
-
) -> Result<Frame> {
|
|
190
|
+
pub fn from_bytes(b: &mut octets::Octets, pkt: packet::Type) -> Result<Frame> {
|
|
193
191
|
let frame_type = b.get_varint()?;
|
|
194
192
|
|
|
195
193
|
let frame = match frame_type {
|
|
@@ -203,16 +201,21 @@ impl Frame {
|
|
|
203
201
|
}
|
|
204
202
|
|
|
205
203
|
Frame::Padding { len }
|
|
206
|
-
}
|
|
204
|
+
}
|
|
207
205
|
|
|
208
206
|
0x01 => Frame::Ping { mtu_probe: None },
|
|
209
207
|
|
|
210
208
|
0x02..=0x03 => parse_ack_frame(frame_type, b)?,
|
|
211
209
|
|
|
212
|
-
0x04 => Frame::ResetStream {
|
|
210
|
+
0x04 | 0x24 => Frame::ResetStream {
|
|
213
211
|
stream_id: b.get_varint()?,
|
|
214
212
|
error_code: b.get_varint()?,
|
|
215
213
|
final_size: b.get_varint()?,
|
|
214
|
+
reliable_size: if frame_type == 0x24 {
|
|
215
|
+
Some(b.get_varint()?)
|
|
216
|
+
} else {
|
|
217
|
+
None
|
|
218
|
+
},
|
|
216
219
|
},
|
|
217
220
|
|
|
218
221
|
0x05 => Frame::StopSending {
|
|
@@ -226,7 +229,7 @@ impl Frame {
|
|
|
226
229
|
let data = <RangeBuf>::from(data.as_ref(), offset, false);
|
|
227
230
|
|
|
228
231
|
Frame::Crypto { data }
|
|
229
|
-
}
|
|
232
|
+
}
|
|
230
233
|
|
|
231
234
|
0x07 => {
|
|
232
235
|
let len = b.get_varint()?;
|
|
@@ -237,7 +240,7 @@ impl Frame {
|
|
|
237
240
|
Frame::NewToken {
|
|
238
241
|
token: b.get_bytes(len as usize)?.to_vec(),
|
|
239
242
|
}
|
|
240
|
-
}
|
|
243
|
+
}
|
|
241
244
|
|
|
242
245
|
0x08..=0x0f => parse_stream_frame(frame_type, b)?,
|
|
243
246
|
|
|
@@ -294,7 +297,7 @@ impl Frame {
|
|
|
294
297
|
.try_into()
|
|
295
298
|
.map_err(|_| Error::BufferTooShort)?,
|
|
296
299
|
}
|
|
297
|
-
}
|
|
300
|
+
}
|
|
298
301
|
|
|
299
302
|
0x19 => Frame::RetireConnectionId {
|
|
300
303
|
seq_num: b.get_varint()?,
|
|
@@ -381,11 +384,11 @@ impl Frame {
|
|
|
381
384
|
|
|
382
385
|
left -= 1;
|
|
383
386
|
}
|
|
384
|
-
}
|
|
387
|
+
}
|
|
385
388
|
|
|
386
389
|
Frame::Ping { .. } => {
|
|
387
390
|
b.put_varint(0x01)?;
|
|
388
|
-
}
|
|
391
|
+
}
|
|
389
392
|
|
|
390
393
|
Frame::ACK {
|
|
391
394
|
ack_delay,
|
|
@@ -425,19 +428,23 @@ impl Frame {
|
|
|
425
428
|
b.put_varint(ecn.ect1_count)?;
|
|
426
429
|
b.put_varint(ecn.ecn_ce_count)?;
|
|
427
430
|
}
|
|
428
|
-
}
|
|
431
|
+
}
|
|
429
432
|
|
|
430
433
|
Frame::ResetStream {
|
|
431
434
|
stream_id,
|
|
432
435
|
error_code,
|
|
433
436
|
final_size,
|
|
437
|
+
reliable_size,
|
|
434
438
|
} => {
|
|
435
|
-
b.put_varint(0x04)?;
|
|
439
|
+
b.put_varint(if reliable_size.is_some() { 0x24 } else { 0x04 })?;
|
|
436
440
|
|
|
437
441
|
b.put_varint(*stream_id)?;
|
|
438
442
|
b.put_varint(*error_code)?;
|
|
439
443
|
b.put_varint(*final_size)?;
|
|
440
|
-
|
|
444
|
+
if let Some(size) = reliable_size {
|
|
445
|
+
b.put_varint(*size)?;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
441
448
|
|
|
442
449
|
Frame::StopSending {
|
|
443
450
|
stream_id,
|
|
@@ -447,13 +454,13 @@ impl Frame {
|
|
|
447
454
|
|
|
448
455
|
b.put_varint(*stream_id)?;
|
|
449
456
|
b.put_varint(*error_code)?;
|
|
450
|
-
}
|
|
457
|
+
}
|
|
451
458
|
|
|
452
459
|
Frame::Crypto { data } => {
|
|
453
460
|
encode_crypto_header(data.off(), data.len() as u64, b)?;
|
|
454
461
|
|
|
455
462
|
b.put_bytes(data)?;
|
|
456
|
-
}
|
|
463
|
+
}
|
|
457
464
|
|
|
458
465
|
Frame::CryptoHeader { .. } => (),
|
|
459
466
|
|
|
@@ -462,19 +469,13 @@ impl Frame {
|
|
|
462
469
|
|
|
463
470
|
b.put_varint(token.len() as u64)?;
|
|
464
471
|
b.put_bytes(token)?;
|
|
465
|
-
}
|
|
472
|
+
}
|
|
466
473
|
|
|
467
474
|
Frame::Stream { stream_id, data } => {
|
|
468
|
-
encode_stream_header(
|
|
469
|
-
*stream_id,
|
|
470
|
-
data.off(),
|
|
471
|
-
data.len() as u64,
|
|
472
|
-
data.fin(),
|
|
473
|
-
b,
|
|
474
|
-
)?;
|
|
475
|
+
encode_stream_header(*stream_id, data.off(), data.len() as u64, data.fin(), b)?;
|
|
475
476
|
|
|
476
477
|
b.put_bytes(data)?;
|
|
477
|
-
}
|
|
478
|
+
}
|
|
478
479
|
|
|
479
480
|
Frame::StreamHeader { .. } => (),
|
|
480
481
|
|
|
@@ -482,51 +483,51 @@ impl Frame {
|
|
|
482
483
|
b.put_varint(0x10)?;
|
|
483
484
|
|
|
484
485
|
b.put_varint(*max)?;
|
|
485
|
-
}
|
|
486
|
+
}
|
|
486
487
|
|
|
487
488
|
Frame::MaxStreamData { stream_id, max } => {
|
|
488
489
|
b.put_varint(0x11)?;
|
|
489
490
|
|
|
490
491
|
b.put_varint(*stream_id)?;
|
|
491
492
|
b.put_varint(*max)?;
|
|
492
|
-
}
|
|
493
|
+
}
|
|
493
494
|
|
|
494
495
|
Frame::MaxStreamsBidi { max } => {
|
|
495
496
|
b.put_varint(0x12)?;
|
|
496
497
|
|
|
497
498
|
b.put_varint(*max)?;
|
|
498
|
-
}
|
|
499
|
+
}
|
|
499
500
|
|
|
500
501
|
Frame::MaxStreamsUni { max } => {
|
|
501
502
|
b.put_varint(0x13)?;
|
|
502
503
|
|
|
503
504
|
b.put_varint(*max)?;
|
|
504
|
-
}
|
|
505
|
+
}
|
|
505
506
|
|
|
506
507
|
Frame::DataBlocked { limit } => {
|
|
507
508
|
b.put_varint(0x14)?;
|
|
508
509
|
|
|
509
510
|
b.put_varint(*limit)?;
|
|
510
|
-
}
|
|
511
|
+
}
|
|
511
512
|
|
|
512
513
|
Frame::StreamDataBlocked { stream_id, limit } => {
|
|
513
514
|
b.put_varint(0x15)?;
|
|
514
515
|
|
|
515
516
|
b.put_varint(*stream_id)?;
|
|
516
517
|
b.put_varint(*limit)?;
|
|
517
|
-
}
|
|
518
|
+
}
|
|
518
519
|
|
|
519
520
|
Frame::StreamsBlockedBidi { limit } => {
|
|
520
521
|
b.put_varint(0x16)?;
|
|
521
522
|
|
|
522
523
|
b.put_varint(*limit)?;
|
|
523
|
-
}
|
|
524
|
+
}
|
|
524
525
|
|
|
525
526
|
Frame::StreamsBlockedUni { limit } => {
|
|
526
527
|
b.put_varint(0x17)?;
|
|
527
528
|
|
|
528
529
|
b.put_varint(*limit)?;
|
|
529
|
-
}
|
|
530
|
+
}
|
|
530
531
|
|
|
531
532
|
Frame::NewConnectionId {
|
|
532
533
|
seq_num,
|
|
@@ -541,25 +542,25 @@ impl Frame {
|
|
|
541
542
|
b.put_u8(conn_id.len() as u8)?;
|
|
542
543
|
b.put_bytes(conn_id.as_ref())?;
|
|
543
544
|
b.put_bytes(reset_token.as_ref())?;
|
|
544
|
-
}
|
|
545
|
+
}
|
|
545
546
|
|
|
546
547
|
Frame::RetireConnectionId { seq_num } => {
|
|
547
548
|
b.put_varint(0x19)?;
|
|
548
549
|
|
|
549
550
|
b.put_varint(*seq_num)?;
|
|
550
|
-
}
|
|
551
|
+
}
|
|
551
552
|
|
|
552
553
|
Frame::PathChallenge { data } => {
|
|
553
554
|
b.put_varint(0x1a)?;
|
|
554
555
|
|
|
555
556
|
b.put_bytes(data.as_ref())?;
|
|
556
|
-
}
|
|
557
|
+
}
|
|
557
558
|
|
|
558
559
|
Frame::PathResponse { data } => {
|
|
559
560
|
b.put_varint(0x1b)?;
|
|
560
561
|
|
|
561
562
|
b.put_bytes(data.as_ref())?;
|
|
562
|
-
}
|
|
563
|
+
}
|
|
563
564
|
|
|
564
565
|
Frame::ConnectionClose {
|
|
565
566
|
error_code,
|
|
@@ -572,7 +573,7 @@ impl Frame {
|
|
|
572
573
|
b.put_varint(*frame_type)?;
|
|
573
574
|
b.put_varint(reason.len() as u64)?;
|
|
574
575
|
b.put_bytes(reason.as_ref())?;
|
|
575
|
-
}
|
|
576
|
+
}
|
|
576
577
|
|
|
577
578
|
Frame::ApplicationClose { error_code, reason } => {
|
|
578
579
|
b.put_varint(0x1d)?;
|
|
@@ -580,17 +581,17 @@ impl Frame {
|
|
|
580
581
|
b.put_varint(*error_code)?;
|
|
581
582
|
b.put_varint(reason.len() as u64)?;
|
|
582
583
|
b.put_bytes(reason.as_ref())?;
|
|
583
|
-
}
|
|
584
|
+
}
|
|
584
585
|
|
|
585
586
|
Frame::HandshakeDone => {
|
|
586
587
|
b.put_varint(0x1e)?;
|
|
587
|
-
}
|
|
588
|
+
}
|
|
588
589
|
|
|
589
590
|
Frame::Datagram { data } => {
|
|
590
591
|
encode_dgram_header(data.len() as u64, b)?;
|
|
591
592
|
|
|
592
593
|
b.put_bytes(data.as_ref())?;
|
|
593
|
-
}
|
|
594
|
+
}
|
|
594
595
|
|
|
595
596
|
Frame::DatagramHeader { .. } => (),
|
|
596
597
|
}
|
|
@@ -633,24 +634,26 @@ impl Frame {
|
|
|
633
634
|
}
|
|
634
635
|
|
|
635
636
|
if let Some(ecn) = ecn_counts {
|
|
636
|
-
len += octets::varint_len(ecn.ect0_count)
|
|
637
|
-
octets::varint_len(ecn.ect1_count)
|
|
638
|
-
octets::varint_len(ecn.ecn_ce_count);
|
|
637
|
+
len += octets::varint_len(ecn.ect0_count)
|
|
638
|
+
+ octets::varint_len(ecn.ect1_count)
|
|
639
|
+
+ octets::varint_len(ecn.ecn_ce_count);
|
|
639
640
|
}
|
|
640
641
|
|
|
641
642
|
len
|
|
642
|
-
}
|
|
643
|
+
}
|
|
643
644
|
|
|
644
645
|
Frame::ResetStream {
|
|
645
646
|
stream_id,
|
|
646
647
|
error_code,
|
|
647
648
|
final_size,
|
|
649
|
+
reliable_size,
|
|
648
650
|
} => {
|
|
649
651
|
1 + // frame type
|
|
650
652
|
octets::varint_len(*stream_id) + // stream_id
|
|
651
653
|
octets::varint_len(*error_code) + // error_code
|
|
652
|
-
octets::varint_len(*final_size)
|
|
653
|
-
|
|
654
|
+
octets::varint_len(*final_size) +
|
|
655
|
+
reliable_size.map_or(0, octets::varint_len)
|
|
656
|
+
}
|
|
654
657
|
|
|
655
658
|
Frame::StopSending {
|
|
656
659
|
stream_id,
|
|
@@ -659,27 +662,27 @@ impl Frame {
|
|
|
659
662
|
1 + // frame type
|
|
660
663
|
octets::varint_len(*stream_id) + // stream_id
|
|
661
664
|
octets::varint_len(*error_code) // error_code
|
|
662
|
-
}
|
|
665
|
+
}
|
|
663
666
|
|
|
664
667
|
Frame::Crypto { data } => {
|
|
665
668
|
1 + // frame type
|
|
666
669
|
octets::varint_len(data.off()) + // offset
|
|
667
670
|
2 + // length, always encode as 2-byte varint
|
|
668
671
|
data.len() // data
|
|
669
|
-
}
|
|
672
|
+
}
|
|
670
673
|
|
|
671
674
|
Frame::CryptoHeader { offset, length, .. } => {
|
|
672
675
|
1 + // frame type
|
|
673
676
|
octets::varint_len(*offset) + // offset
|
|
674
677
|
2 + // length, always encode as 2-byte varint
|
|
675
678
|
length // data
|
|
676
|
-
}
|
|
679
|
+
}
|
|
677
680
|
|
|
678
681
|
Frame::NewToken { token } => {
|
|
679
682
|
1 + // frame type
|
|
680
683
|
octets::varint_len(token.len() as u64) + // token length
|
|
681
684
|
token.len() // token
|
|
682
|
-
}
|
|
685
|
+
}
|
|
683
686
|
|
|
684
687
|
Frame::Stream { stream_id, data } => {
|
|
685
688
|
1 + // frame type
|
|
@@ -687,7 +690,7 @@ impl Frame {
|
|
|
687
690
|
octets::varint_len(data.off()) + // offset
|
|
688
691
|
2 + // length, always encode as 2-byte varint
|
|
689
692
|
data.len() // data
|
|
690
|
-
}
|
|
693
|
+
}
|
|
691
694
|
|
|
692
695
|
Frame::StreamHeader {
|
|
693
696
|
stream_id,
|
|
@@ -700,49 +703,49 @@ impl Frame {
|
|
|
700
703
|
octets::varint_len(*offset) + // offset
|
|
701
704
|
2 + // length, always encode as 2-byte varint
|
|
702
705
|
length // data
|
|
703
|
-
}
|
|
706
|
+
}
|
|
704
707
|
|
|
705
708
|
Frame::MaxData { max } => {
|
|
706
709
|
1 + // frame type
|
|
707
710
|
octets::varint_len(*max) // max
|
|
708
|
-
}
|
|
711
|
+
}
|
|
709
712
|
|
|
710
713
|
Frame::MaxStreamData { stream_id, max } => {
|
|
711
714
|
1 + // frame type
|
|
712
715
|
octets::varint_len(*stream_id) + // stream_id
|
|
713
716
|
octets::varint_len(*max) // max
|
|
714
|
-
}
|
|
717
|
+
}
|
|
715
718
|
|
|
716
719
|
Frame::MaxStreamsBidi { max } => {
|
|
717
720
|
1 + // frame type
|
|
718
721
|
octets::varint_len(*max) // max
|
|
719
|
-
}
|
|
722
|
+
}
|
|
720
723
|
|
|
721
724
|
Frame::MaxStreamsUni { max } => {
|
|
722
725
|
1 + // frame type
|
|
723
726
|
octets::varint_len(*max) // max
|
|
724
|
-
}
|
|
727
|
+
}
|
|
725
728
|
|
|
726
729
|
Frame::DataBlocked { limit } => {
|
|
727
730
|
1 + // frame type
|
|
728
731
|
octets::varint_len(*limit) // limit
|
|
729
|
-
}
|
|
732
|
+
}
|
|
730
733
|
|
|
731
734
|
Frame::StreamDataBlocked { stream_id, limit } => {
|
|
732
735
|
1 + // frame type
|
|
733
736
|
octets::varint_len(*stream_id) + // stream_id
|
|
734
737
|
octets::varint_len(*limit) // limit
|
|
735
|
-
}
|
|
738
|
+
}
|
|
736
739
|
|
|
737
740
|
Frame::StreamsBlockedBidi { limit } => {
|
|
738
741
|
1 + // frame type
|
|
739
742
|
octets::varint_len(*limit) // limit
|
|
740
|
-
}
|
|
743
|
+
}
|
|
741
744
|
|
|
742
745
|
Frame::StreamsBlockedUni { limit } => {
|
|
743
746
|
1 + // frame type
|
|
744
747
|
octets::varint_len(*limit) // limit
|
|
745
|
-
}
|
|
748
|
+
}
|
|
746
749
|
|
|
747
750
|
Frame::NewConnectionId {
|
|
748
751
|
seq_num,
|
|
@@ -756,22 +759,22 @@ impl Frame {
|
|
|
756
759
|
1 + // conn_id length
|
|
757
760
|
conn_id.len() + // conn_id
|
|
758
761
|
reset_token.len() // reset_token
|
|
759
|
-
}
|
|
762
|
+
}
|
|
760
763
|
|
|
761
764
|
Frame::RetireConnectionId { seq_num } => {
|
|
762
765
|
1 + // frame type
|
|
763
766
|
octets::varint_len(*seq_num) // seq_num
|
|
764
|
-
}
|
|
767
|
+
}
|
|
765
768
|
|
|
766
769
|
Frame::PathChallenge { .. } => {
|
|
767
770
|
1 + // frame type
|
|
768
771
|
8 // data
|
|
769
|
-
}
|
|
772
|
+
}
|
|
770
773
|
|
|
771
774
|
Frame::PathResponse { .. } => {
|
|
772
775
|
1 + // frame type
|
|
773
776
|
8 // data
|
|
774
|
-
}
|
|
777
|
+
}
|
|
775
778
|
|
|
776
779
|
Frame::ConnectionClose {
|
|
777
780
|
frame_type,
|
|
@@ -784,30 +787,30 @@ impl Frame {
|
|
|
784
787
|
octets::varint_len(*frame_type) + // frame_type
|
|
785
788
|
octets::varint_len(reason.len() as u64) + // reason_len
|
|
786
789
|
reason.len() // reason
|
|
787
|
-
}
|
|
790
|
+
}
|
|
788
791
|
|
|
789
792
|
Frame::ApplicationClose { reason, error_code } => {
|
|
790
793
|
1 + // frame type
|
|
791
794
|
octets::varint_len(*error_code) + // error_code
|
|
792
795
|
octets::varint_len(reason.len() as u64) + // reason_len
|
|
793
796
|
reason.len() // reason
|
|
794
|
-
}
|
|
797
|
+
}
|
|
795
798
|
|
|
796
799
|
Frame::HandshakeDone => {
|
|
797
800
|
1 // frame type
|
|
798
|
-
}
|
|
801
|
+
}
|
|
799
802
|
|
|
800
803
|
Frame::Datagram { data } => {
|
|
801
804
|
1 + // frame type
|
|
802
805
|
2 + // length, always encode as 2-byte varint
|
|
803
806
|
data.len() // data
|
|
804
|
-
}
|
|
807
|
+
}
|
|
805
808
|
|
|
806
809
|
Frame::DatagramHeader { length } => {
|
|
807
810
|
1 + // frame type
|
|
808
811
|
2 + // length, always encode as 2-byte varint
|
|
809
812
|
*length // data
|
|
810
|
-
}
|
|
813
|
+
}
|
|
811
814
|
}
|
|
812
815
|
}
|
|
813
816
|
|
|
@@ -815,20 +818,20 @@ impl Frame {
|
|
|
815
818
|
// Any other frame is ack-eliciting (note the `!`).
|
|
816
819
|
!matches!(
|
|
817
820
|
self,
|
|
818
|
-
Frame::Padding { .. }
|
|
819
|
-
Frame::ACK { .. }
|
|
820
|
-
Frame::ApplicationClose { .. }
|
|
821
|
-
Frame::ConnectionClose { .. }
|
|
821
|
+
Frame::Padding { .. }
|
|
822
|
+
| Frame::ACK { .. }
|
|
823
|
+
| Frame::ApplicationClose { .. }
|
|
824
|
+
| Frame::ConnectionClose { .. }
|
|
822
825
|
)
|
|
823
826
|
}
|
|
824
827
|
|
|
825
828
|
pub fn probing(&self) -> bool {
|
|
826
829
|
matches!(
|
|
827
830
|
self,
|
|
828
|
-
Frame::Padding { .. }
|
|
829
|
-
Frame::NewConnectionId { .. }
|
|
830
|
-
Frame::PathChallenge { .. }
|
|
831
|
-
Frame::PathResponse { .. }
|
|
831
|
+
Frame::Padding { .. }
|
|
832
|
+
| Frame::NewConnectionId { .. }
|
|
833
|
+
| Frame::PathChallenge { .. }
|
|
834
|
+
| Frame::PathResponse { .. }
|
|
832
835
|
)
|
|
833
836
|
}
|
|
834
837
|
|
|
@@ -876,12 +879,13 @@ impl Frame {
|
|
|
876
879
|
ce,
|
|
877
880
|
raw: None,
|
|
878
881
|
}
|
|
879
|
-
}
|
|
882
|
+
}
|
|
880
883
|
|
|
881
884
|
Frame::ResetStream {
|
|
882
885
|
stream_id,
|
|
883
886
|
error_code,
|
|
884
887
|
final_size,
|
|
888
|
+
..
|
|
885
889
|
} => QuicFrame::ResetStream {
|
|
886
890
|
stream_id: *stream_id,
|
|
887
891
|
error: qlog::events::ApplicationError::Unknown,
|
|
@@ -923,8 +927,7 @@ impl Frame {
|
|
|
923
927
|
// TODO: pick the token type some how
|
|
924
928
|
ty: Some(qlog::TokenType::Retry),
|
|
925
929
|
raw: Some(RawInfo {
|
|
926
|
-
data: qlog::HexSlice::maybe_string(Some(token))
|
|
927
|
-
.map(Box::new),
|
|
930
|
+
data: qlog::HexSlice::maybe_string(Some(token)).map(Box::new),
|
|
928
931
|
length: Some(token.len() as u64),
|
|
929
932
|
payload_length: None,
|
|
930
933
|
}),
|
|
@@ -988,12 +991,11 @@ impl Frame {
|
|
|
988
991
|
raw: None,
|
|
989
992
|
},
|
|
990
993
|
|
|
991
|
-
Frame::StreamDataBlocked { stream_id, limit } =>
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
},
|
|
994
|
+
Frame::StreamDataBlocked { stream_id, limit } => QuicFrame::StreamDataBlocked {
|
|
995
|
+
stream_id: *stream_id,
|
|
996
|
+
limit: *limit,
|
|
997
|
+
raw: None,
|
|
998
|
+
},
|
|
997
999
|
|
|
998
1000
|
Frame::StreamsBlockedBidi { limit } => QuicFrame::StreamsBlocked {
|
|
999
1001
|
stream_type: StreamType::Bidirectional,
|
|
@@ -1017,17 +1019,14 @@ impl Frame {
|
|
|
1017
1019
|
retire_prior_to: *retire_prior_to,
|
|
1018
1020
|
connection_id_length: Some(conn_id.len() as u8),
|
|
1019
1021
|
connection_id: format!("{}", qlog::HexSlice::new(conn_id)),
|
|
1020
|
-
stateless_reset_token: qlog::HexSlice::maybe_string(Some(
|
|
1021
|
-
reset_token,
|
|
1022
|
-
)),
|
|
1022
|
+
stateless_reset_token: qlog::HexSlice::maybe_string(Some(reset_token)),
|
|
1023
1023
|
raw: None,
|
|
1024
1024
|
},
|
|
1025
1025
|
|
|
1026
|
-
Frame::RetireConnectionId { seq_num } =>
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
},
|
|
1026
|
+
Frame::RetireConnectionId { seq_num } => QuicFrame::RetireConnectionId {
|
|
1027
|
+
sequence_number: *seq_num,
|
|
1028
|
+
raw: None,
|
|
1029
|
+
},
|
|
1031
1030
|
|
|
1032
1031
|
Frame::PathChallenge { .. } => QuicFrame::PathChallenge {
|
|
1033
1032
|
data: None,
|
|
@@ -1064,7 +1063,7 @@ impl Frame {
|
|
|
1064
1063
|
reason_bytes: None,
|
|
1065
1064
|
trigger_frame_type: None, // don't know trigger type
|
|
1066
1065
|
}
|
|
1067
|
-
}
|
|
1066
|
+
}
|
|
1068
1067
|
|
|
1069
1068
|
Frame::HandshakeDone => QuicFrame::HandshakeDone { raw: None },
|
|
1070
1069
|
|
|
@@ -1092,11 +1091,11 @@ impl std::fmt::Debug for Frame {
|
|
|
1092
1091
|
match self {
|
|
1093
1092
|
Frame::Padding { len } => {
|
|
1094
1093
|
write!(f, "PADDING len={len}")?;
|
|
1095
|
-
}
|
|
1094
|
+
}
|
|
1096
1095
|
|
|
1097
1096
|
Frame::Ping { mtu_probe } => {
|
|
1098
1097
|
write!(f, "PING mtu_probe={mtu_probe:?}")?;
|
|
1099
|
-
}
|
|
1098
|
+
}
|
|
1100
1099
|
|
|
1101
1100
|
Frame::ACK {
|
|
1102
1101
|
ack_delay,
|
|
@@ -1107,37 +1106,41 @@ impl std::fmt::Debug for Frame {
|
|
|
1107
1106
|
f,
|
|
1108
1107
|
"ACK delay={ack_delay} blocks={ranges:?} ecn_counts={ecn_counts:?}"
|
|
1109
1108
|
)?;
|
|
1110
|
-
}
|
|
1109
|
+
}
|
|
1111
1110
|
|
|
1112
1111
|
Frame::ResetStream {
|
|
1113
1112
|
stream_id,
|
|
1114
1113
|
error_code,
|
|
1115
1114
|
final_size,
|
|
1115
|
+
reliable_size,
|
|
1116
1116
|
} => {
|
|
1117
1117
|
write!(
|
|
1118
1118
|
f,
|
|
1119
1119
|
"RESET_STREAM stream={stream_id} err={error_code:x} size={final_size}"
|
|
1120
1120
|
)?;
|
|
1121
|
-
|
|
1121
|
+
if let Some(size) = reliable_size {
|
|
1122
|
+
write!(f, " reliable_size={size}")?;
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1122
1125
|
|
|
1123
1126
|
Frame::StopSending {
|
|
1124
1127
|
stream_id,
|
|
1125
1128
|
error_code,
|
|
1126
1129
|
} => {
|
|
1127
1130
|
write!(f, "STOP_SENDING stream={stream_id} err={error_code:x}")?;
|
|
1128
|
-
}
|
|
1131
|
+
}
|
|
1129
1132
|
|
|
1130
1133
|
Frame::Crypto { data } => {
|
|
1131
1134
|
write!(f, "CRYPTO off={} len={}", data.off(), data.len())?;
|
|
1132
|
-
}
|
|
1135
|
+
}
|
|
1133
1136
|
|
|
1134
1137
|
Frame::CryptoHeader { offset, length } => {
|
|
1135
1138
|
write!(f, "CRYPTO off={offset} len={length}")?;
|
|
1136
|
-
}
|
|
1139
|
+
}
|
|
1137
1140
|
|
|
1138
1141
|
Frame::NewToken { token } => {
|
|
1139
1142
|
write!(f, "NEW_TOKEN len={}", token.len())?;
|
|
1140
|
-
}
|
|
1143
|
+
}
|
|
1141
1144
|
|
|
1142
1145
|
Frame::Stream { stream_id, data } => {
|
|
1143
1146
|
write!(
|
|
@@ -1148,7 +1151,7 @@ impl std::fmt::Debug for Frame {
|
|
|
1148
1151
|
data.len(),
|
|
1149
1152
|
data.fin()
|
|
1150
1153
|
)?;
|
|
1151
|
-
}
|
|
1154
|
+
}
|
|
1152
1155
|
|
|
1153
1156
|
Frame::StreamHeader {
|
|
1154
1157
|
stream_id,
|
|
@@ -1160,42 +1163,39 @@ impl std::fmt::Debug for Frame {
|
|
|
1160
1163
|
f,
|
|
1161
1164
|
"STREAM id={stream_id} off={offset} len={length} fin={fin}"
|
|
1162
1165
|
)?;
|
|
1163
|
-
}
|
|
1166
|
+
}
|
|
1164
1167
|
|
|
1165
1168
|
Frame::MaxData { max } => {
|
|
1166
1169
|
write!(f, "MAX_DATA max={max}")?;
|
|
1167
|
-
}
|
|
1170
|
+
}
|
|
1168
1171
|
|
|
1169
1172
|
Frame::MaxStreamData { stream_id, max } => {
|
|
1170
1173
|
write!(f, "MAX_STREAM_DATA stream={stream_id} max={max}")?;
|
|
1171
|
-
}
|
|
1174
|
+
}
|
|
1172
1175
|
|
|
1173
1176
|
Frame::MaxStreamsBidi { max } => {
|
|
1174
1177
|
write!(f, "MAX_STREAMS type=bidi max={max}")?;
|
|
1175
|
-
}
|
|
1178
|
+
}
|
|
1176
1179
|
|
|
1177
1180
|
Frame::MaxStreamsUni { max } => {
|
|
1178
1181
|
write!(f, "MAX_STREAMS type=uni max={max}")?;
|
|
1179
|
-
}
|
|
1182
|
+
}
|
|
1180
1183
|
|
|
1181
1184
|
Frame::DataBlocked { limit } => {
|
|
1182
1185
|
write!(f, "DATA_BLOCKED limit={limit}")?;
|
|
1183
|
-
}
|
|
1186
|
+
}
|
|
1184
1187
|
|
|
1185
1188
|
Frame::StreamDataBlocked { stream_id, limit } => {
|
|
1186
|
-
write!(
|
|
1187
|
-
|
|
1188
|
-
"STREAM_DATA_BLOCKED stream={stream_id} limit={limit}"
|
|
1189
|
-
)?;
|
|
1190
|
-
},
|
|
1189
|
+
write!(f, "STREAM_DATA_BLOCKED stream={stream_id} limit={limit}")?;
|
|
1190
|
+
}
|
|
1191
1191
|
|
|
1192
1192
|
Frame::StreamsBlockedBidi { limit } => {
|
|
1193
1193
|
write!(f, "STREAMS_BLOCKED type=bidi limit={limit}")?;
|
|
1194
|
-
}
|
|
1194
|
+
}
|
|
1195
1195
|
|
|
1196
1196
|
Frame::StreamsBlockedUni { limit } => {
|
|
1197
1197
|
write!(f, "STREAMS_BLOCKED type=uni limit={limit}")?;
|
|
1198
|
-
}
|
|
1198
|
+
}
|
|
1199
1199
|
|
|
1200
1200
|
Frame::NewConnectionId {
|
|
1201
1201
|
seq_num,
|
|
@@ -1207,19 +1207,19 @@ impl std::fmt::Debug for Frame {
|
|
|
1207
1207
|
f,
|
|
1208
1208
|
"NEW_CONNECTION_ID seq_num={seq_num} retire_prior_to={retire_prior_to} conn_id={conn_id:02x?} reset_token={reset_token:02x?}",
|
|
1209
1209
|
)?;
|
|
1210
|
-
}
|
|
1210
|
+
}
|
|
1211
1211
|
|
|
1212
1212
|
Frame::RetireConnectionId { seq_num } => {
|
|
1213
1213
|
write!(f, "RETIRE_CONNECTION_ID seq_num={seq_num}")?;
|
|
1214
|
-
}
|
|
1214
|
+
}
|
|
1215
1215
|
|
|
1216
1216
|
Frame::PathChallenge { data } => {
|
|
1217
1217
|
write!(f, "PATH_CHALLENGE data={data:02x?}")?;
|
|
1218
|
-
}
|
|
1218
|
+
}
|
|
1219
1219
|
|
|
1220
1220
|
Frame::PathResponse { data } => {
|
|
1221
1221
|
write!(f, "PATH_RESPONSE data={data:02x?}")?;
|
|
1222
|
-
}
|
|
1222
|
+
}
|
|
1223
1223
|
|
|
1224
1224
|
Frame::ConnectionClose {
|
|
1225
1225
|
error_code,
|
|
@@ -1230,26 +1230,23 @@ impl std::fmt::Debug for Frame {
|
|
|
1230
1230
|
f,
|
|
1231
1231
|
"CONNECTION_CLOSE err={error_code:x} frame={frame_type:x} reason={reason:x?}"
|
|
1232
1232
|
)?;
|
|
1233
|
-
}
|
|
1233
|
+
}
|
|
1234
1234
|
|
|
1235
1235
|
Frame::ApplicationClose { error_code, reason } => {
|
|
1236
|
-
write!(
|
|
1237
|
-
|
|
1238
|
-
"APPLICATION_CLOSE err={error_code:x} reason={reason:x?}"
|
|
1239
|
-
)?;
|
|
1240
|
-
},
|
|
1236
|
+
write!(f, "APPLICATION_CLOSE err={error_code:x} reason={reason:x?}")?;
|
|
1237
|
+
}
|
|
1241
1238
|
|
|
1242
1239
|
Frame::HandshakeDone => {
|
|
1243
1240
|
write!(f, "HANDSHAKE_DONE")?;
|
|
1244
|
-
}
|
|
1241
|
+
}
|
|
1245
1242
|
|
|
1246
1243
|
Frame::Datagram { data } => {
|
|
1247
1244
|
write!(f, "DATAGRAM len={}", data.len())?;
|
|
1248
|
-
}
|
|
1245
|
+
}
|
|
1249
1246
|
|
|
1250
1247
|
Frame::DatagramHeader { length } => {
|
|
1251
1248
|
write!(f, "DATAGRAM len={length}")?;
|
|
1252
|
-
}
|
|
1249
|
+
}
|
|
1253
1250
|
}
|
|
1254
1251
|
|
|
1255
1252
|
Ok(())
|
|
@@ -1312,9 +1309,7 @@ fn parse_ack_frame(ty: u64, b: &mut octets::Octets) -> Result<Frame> {
|
|
|
1312
1309
|
})
|
|
1313
1310
|
}
|
|
1314
1311
|
|
|
1315
|
-
pub fn encode_crypto_header(
|
|
1316
|
-
offset: u64, length: u64, b: &mut octets::OctetsMut,
|
|
1317
|
-
) -> Result<()> {
|
|
1312
|
+
pub fn encode_crypto_header(offset: u64, length: u64, b: &mut octets::OctetsMut) -> Result<()> {
|
|
1318
1313
|
b.put_varint(0x06)?;
|
|
1319
1314
|
|
|
1320
1315
|
b.put_varint(offset)?;
|
|
@@ -1326,7 +1321,10 @@ pub fn encode_crypto_header(
|
|
|
1326
1321
|
}
|
|
1327
1322
|
|
|
1328
1323
|
pub fn encode_stream_header(
|
|
1329
|
-
stream_id: u64,
|
|
1324
|
+
stream_id: u64,
|
|
1325
|
+
offset: u64,
|
|
1326
|
+
length: u64,
|
|
1327
|
+
fin: bool,
|
|
1330
1328
|
b: &mut octets::OctetsMut,
|
|
1331
1329
|
) -> Result<()> {
|
|
1332
1330
|
let mut ty: u8 = 0x08;
|
|
@@ -1554,6 +1552,7 @@ mod tests {
|
|
|
1554
1552
|
stream_id: 123_213,
|
|
1555
1553
|
error_code: 21_123_767,
|
|
1556
1554
|
final_size: 21_123_767,
|
|
1555
|
+
reliable_size: None,
|
|
1557
1556
|
};
|
|
1558
1557
|
|
|
1559
1558
|
let wire_len = {
|