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.
Files changed (99) hide show
  1. package/Cargo.lock +523 -140
  2. package/Cargo.toml +5 -5
  3. package/README.md +8 -4
  4. package/crates/echo-server/src/bin/gen-test-cert.rs +1 -1
  5. package/crates/native/Cargo.toml +2 -0
  6. package/crates/native/src/config.rs +69 -8
  7. package/crates/native/src/driver.rs +253 -90
  8. package/crates/native/src/lib.rs +80 -57
  9. package/crates/native/src/parser_memory.rs +203 -0
  10. package/crates/native/src/server.rs +215 -183
  11. package/crates/native/src/session.rs +1341 -243
  12. package/crates/native/src/test_support.rs +119 -0
  13. package/crates/wtcore/Cargo.toml +1 -0
  14. package/crates/wtcore/src/h3.rs +250 -46
  15. package/dist/index.js +218 -75
  16. package/dist/index.js.map +7 -1
  17. package/dist/index.mjs +214 -69
  18. package/dist/index.mjs.map +7 -1
  19. package/dist/native.d.ts +10 -4
  20. package/dist/server.d.ts +1 -0
  21. package/package.json +84 -78
  22. package/prebuilds/darwin-arm64/rwebtransport.node +0 -0
  23. package/prebuilds/linux-arm64/rwebtransport.node +0 -0
  24. package/prebuilds/linux-x64/rwebtransport.node +0 -0
  25. package/prebuilds/win32-x64/rwebtransport.node +0 -0
  26. package/scripts/build-linux-prebuilt.sh +46 -0
  27. package/scripts/build-ts.js +41 -0
  28. package/scripts/build.js +10 -3
  29. package/vendor/quiche/AGENTS.md +10 -0
  30. package/vendor/quiche/Cargo.lock +239 -248
  31. package/vendor/quiche/Cargo.toml +23 -10
  32. package/vendor/quiche/examples/Makefile +4 -4
  33. package/vendor/quiche/examples/client.rs +10 -28
  34. package/vendor/quiche/examples/http3-client.rs +20 -34
  35. package/vendor/quiche/examples/http3-server.rs +47 -78
  36. package/vendor/quiche/examples/server.rs +19 -49
  37. package/vendor/quiche/include/quiche.h +35 -4
  38. package/vendor/quiche/src/build.rs +17 -0
  39. package/vendor/quiche/src/cid.rs +129 -61
  40. package/vendor/quiche/src/crypto/boringssl.rs +98 -86
  41. package/vendor/quiche/src/crypto/mod.rs +64 -77
  42. package/vendor/quiche/src/dgram.rs +2 -3
  43. package/vendor/quiche/src/error.rs +22 -20
  44. package/vendor/quiche/src/ffi.rs +558 -280
  45. package/vendor/quiche/src/flowcontrol.rs +0 -7
  46. package/vendor/quiche/src/frame.rs +134 -135
  47. package/vendor/quiche/src/h3/ffi.rs +73 -60
  48. package/vendor/quiche/src/h3/frame.rs +70 -90
  49. package/vendor/quiche/src/h3/mod.rs +1024 -593
  50. package/vendor/quiche/src/h3/qpack/decoder.rs +248 -34
  51. package/vendor/quiche/src/h3/qpack/dynamic_table.rs +859 -0
  52. package/vendor/quiche/src/h3/qpack/encoder.rs +14 -17
  53. package/vendor/quiche/src/h3/qpack/mod.rs +48 -0
  54. package/vendor/quiche/src/h3/qpack/static_table.rs +86 -73
  55. package/vendor/quiche/src/h3/stream.rs +1009 -194
  56. package/vendor/quiche/src/lib.rs +1361 -1195
  57. package/vendor/quiche/src/minmax.rs +2 -6
  58. package/vendor/quiche/src/packet.rs +420 -552
  59. package/vendor/quiche/src/path.rs +202 -72
  60. package/vendor/quiche/src/pmtud.rs +18 -16
  61. package/vendor/quiche/src/ranges.rs +184 -82
  62. package/vendor/quiche/src/recovery/AGENTS.md +5 -2
  63. package/vendor/quiche/src/recovery/bandwidth.rs +59 -40
  64. package/vendor/quiche/src/recovery/bytes_in_flight.rs +2 -2
  65. package/vendor/quiche/src/recovery/congestion/cubic.rs +38 -47
  66. package/vendor/quiche/src/recovery/congestion/delivery_rate.rs +54 -60
  67. package/vendor/quiche/src/recovery/congestion/hystart.rs +6 -10
  68. package/vendor/quiche/src/recovery/congestion/mod.rs +110 -42
  69. package/vendor/quiche/src/recovery/congestion/prr.rs +4 -1
  70. package/vendor/quiche/src/recovery/congestion/recovery.rs +91 -95
  71. package/vendor/quiche/src/recovery/congestion/reno.rs +17 -12
  72. package/vendor/quiche/src/recovery/congestion/test_sender.rs +8 -27
  73. package/vendor/quiche/src/recovery/gcongestion/bbr/bandwidth_sampler.rs +159 -247
  74. package/vendor/quiche/src/recovery/gcongestion/bbr/windowed_filter.rs +9 -14
  75. package/vendor/quiche/src/recovery/gcongestion/bbr2/drain.rs +18 -15
  76. package/vendor/quiche/src/recovery/gcongestion/bbr2/mode.rs +43 -28
  77. package/vendor/quiche/src/recovery/gcongestion/bbr2/network_model.rs +349 -76
  78. package/vendor/quiche/src/recovery/gcongestion/bbr2/probe_bw.rs +147 -195
  79. package/vendor/quiche/src/recovery/gcongestion/bbr2/probe_rtt.rs +29 -27
  80. package/vendor/quiche/src/recovery/gcongestion/bbr2/rtt_jump_detector/global_min.rs +180 -0
  81. package/vendor/quiche/src/recovery/gcongestion/bbr2/rtt_jump_detector/global_min_tests.rs +221 -0
  82. package/vendor/quiche/src/recovery/gcongestion/bbr2/rtt_jump_detector/hmm.rs +395 -0
  83. package/vendor/quiche/src/recovery/gcongestion/bbr2/rtt_jump_detector/hmm_tests.rs +473 -0
  84. package/vendor/quiche/src/recovery/gcongestion/bbr2/rtt_jump_detector/mod.rs +175 -0
  85. package/vendor/quiche/src/recovery/gcongestion/bbr2/startup.rs +33 -26
  86. package/vendor/quiche/src/recovery/gcongestion/bbr2.rs +107 -60
  87. package/vendor/quiche/src/recovery/gcongestion/mod.rs +64 -11
  88. package/vendor/quiche/src/recovery/gcongestion/pacer.rs +34 -25
  89. package/vendor/quiche/src/recovery/gcongestion/recovery.rs +81 -86
  90. package/vendor/quiche/src/recovery/mod.rs +414 -173
  91. package/vendor/quiche/src/recovery/rtt.rs +8 -5
  92. package/vendor/quiche/src/stream/mod.rs +864 -133
  93. package/vendor/quiche/src/stream/recv_buf.rs +476 -172
  94. package/vendor/quiche/src/stream/send_buf.rs +343 -81
  95. package/vendor/quiche/src/test_utils.rs +78 -64
  96. package/vendor/quiche/src/tests.rs +2559 -1335
  97. package/vendor/quiche/src/tls/boringssl.rs +60 -63
  98. package/vendor/quiche/src/tls/mod.rs +146 -193
  99. package/vendor/quiche/src/transport_params.rs +87 -103
@@ -88,9 +88,7 @@ where
88
88
  if match &self.estimates[0] {
89
89
  None => true,
90
90
  Some(best) if new_sample > best.sample => true,
91
- _ =>
92
- new_time - self.estimates[2].as_ref().unwrap().time >
93
- self.window_length,
91
+ _ => new_time - self.estimates[2].as_ref().unwrap().time > self.window_length,
94
92
  } {
95
93
  return self.reset(new_sample, new_time);
96
94
  }
@@ -118,10 +116,8 @@ where
118
116
  sample: new_sample,
119
117
  time: new_time,
120
118
  });
121
- // Need to iterate one more time. Check if the new best estimate is
122
- // outside the window as well, since it may also have been recorded a
123
- // long time ago. Don't need to iterate once more since we cover that
124
- // case at the beginning of the method.
119
+ // The new best estimate may also be stale. Check it once more. The
120
+ // check at the start of the method handles further stale samples.
125
121
  if new_time - self.estimates[0].unwrap().time > self.window_length {
126
122
  self.estimates[0] = self.estimates[1];
127
123
  self.estimates[1] = self.estimates[2];
@@ -129,12 +125,11 @@ where
129
125
  return;
130
126
  }
131
127
 
132
- if self.estimates[1].unwrap().sample == self.estimates[0].unwrap().sample &&
133
- new_time - self.estimates[1].unwrap().time > self.window_length / 4
128
+ if self.estimates[1].unwrap().sample == self.estimates[0].unwrap().sample
129
+ && new_time - self.estimates[1].unwrap().time > self.window_length / 4
134
130
  {
135
- // A quarter of the window has passed without a better sample, so the
136
- // second-best estimate is taken from the second quarter of the
137
- // window.
131
+ // No better sample arrived for a quarter of the window, so take the
132
+ // second-best estimate from the second quarter.
138
133
  self.estimates[1] = Some(Sample {
139
134
  sample: new_sample,
140
135
  time: new_time,
@@ -143,8 +138,8 @@ where
143
138
  return;
144
139
  }
145
140
 
146
- if self.estimates[2].unwrap().sample == self.estimates[1].unwrap().sample &&
147
- new_time - self.estimates[2].unwrap().time > self.window_length / 2
141
+ if self.estimates[2].unwrap().sample == self.estimates[1].unwrap().sample
142
+ && new_time - self.estimates[2].unwrap().time > self.window_length / 2
148
143
  {
149
144
  // We've passed a half of the window without a better estimate, so
150
145
  // take a third-best estimate from the second half of the
@@ -59,11 +59,16 @@ impl ModeImpl for Drain {
59
59
  }
60
60
 
61
61
  fn on_congestion_event(
62
- mut self, _prior_in_flight: usize, event_time: Instant,
63
- _acked_packets: &[Acked], _lost_packets: &[Lost],
62
+ mut self,
63
+ _prior_in_flight: usize,
64
+ event_time: Instant,
65
+ _acked_packets: &[Acked],
66
+ _lost_packets: &[Lost],
64
67
  congestion_event: &mut BBRv2CongestionEvent,
65
- _target_bytes_inflight: usize, params: &Params,
66
- _recovery_stats: &mut RecoveryStats, _cwnd: usize,
68
+ _target_bytes_inflight: usize,
69
+ params: &Params,
70
+ _recovery_stats: &mut RecoveryStats,
71
+ _cwnd: usize,
67
72
  ) -> Mode {
68
73
  self.model.set_pacing_gain(params.drain_pacing_gain);
69
74
  // Only STARTUP can transition to DRAIN, both of them use the same cwnd
@@ -72,11 +77,7 @@ impl ModeImpl for Drain {
72
77
 
73
78
  let drain_target = self.drain_target();
74
79
  if congestion_event.bytes_in_flight <= drain_target {
75
- return self.into_probe_bw(
76
- event_time,
77
- Some(congestion_event),
78
- params,
79
- );
80
+ return self.into_probe_bw(event_time, Some(congestion_event), params);
80
81
  }
81
82
 
82
83
  Mode::Drain(self)
@@ -90,22 +91,24 @@ impl ModeImpl for Drain {
90
91
  }
91
92
 
92
93
  fn on_exit_quiescence(
93
- self, _now: Instant, _quiescence_start_time: Instant, _params: &Params,
94
+ self,
95
+ _now: Instant,
96
+ _quiescence_start_time: Instant,
97
+ _params: &Params,
94
98
  ) -> Mode {
95
99
  Mode::Drain(self)
96
100
  }
97
101
 
98
- fn enter(
99
- &mut self, _: Instant, _: Option<&BBRv2CongestionEvent>, _params: &Params,
100
- ) {
101
- }
102
+ fn enter(&mut self, _: Instant, _: Option<&BBRv2CongestionEvent>, _params: &Params) {}
102
103
 
103
104
  fn leave(&mut self, _: Instant, _: Option<&BBRv2CongestionEvent>) {}
104
105
  }
105
106
 
106
107
  impl Drain {
107
108
  fn into_probe_bw(
108
- mut self, now: Instant, congestion_event: Option<&BBRv2CongestionEvent>,
109
+ mut self,
110
+ now: Instant,
111
+ congestion_event: Option<&BBRv2CongestionEvent>,
109
112
  params: &Params,
110
113
  ) -> Mode {
111
114
  self.leave(now, congestion_event);
@@ -123,29 +123,37 @@ pub(super) trait ModeImpl: Debug {
123
123
  fn state_str(&self) -> &'static str;
124
124
 
125
125
  fn enter(
126
- &mut self, now: Instant, congestion_event: Option<&BBRv2CongestionEvent>,
126
+ &mut self,
127
+ now: Instant,
128
+ congestion_event: Option<&BBRv2CongestionEvent>,
127
129
  params: &Params,
128
130
  );
129
131
 
130
- fn leave(
131
- &mut self, now: Instant, congestion_event: Option<&BBRv2CongestionEvent>,
132
- );
132
+ fn leave(&mut self, now: Instant, congestion_event: Option<&BBRv2CongestionEvent>);
133
133
 
134
134
  fn is_probing_for_bandwidth(&self) -> bool;
135
135
 
136
136
  #[allow(clippy::too_many_arguments)]
137
137
  fn on_congestion_event(
138
- self, prior_in_flight: usize, event_time: Instant,
139
- acked_packets: &[Acked], lost_packets: &[Lost],
138
+ self,
139
+ prior_in_flight: usize,
140
+ event_time: Instant,
141
+ acked_packets: &[Acked],
142
+ lost_packets: &[Lost],
140
143
  congestion_event: &mut BBRv2CongestionEvent,
141
- target_bytes_inflight: usize, params: &Params,
142
- recovery_stats: &mut RecoveryStats, cwnd: usize,
144
+ target_bytes_inflight: usize,
145
+ params: &Params,
146
+ recovery_stats: &mut RecoveryStats,
147
+ cwnd: usize,
143
148
  ) -> Mode;
144
149
 
145
150
  fn get_cwnd_limits(&self, params: &Params) -> Limits<usize>;
146
151
 
147
152
  fn on_exit_quiescence(
148
- self, now: Instant, quiescence_start_time: Instant, params: &Params,
153
+ self,
154
+ now: Instant,
155
+ quiescence_start_time: Instant,
156
+ params: &Params,
149
157
  ) -> Mode;
150
158
  }
151
159
 
@@ -187,11 +195,16 @@ impl Mode {
187
195
 
188
196
  #[allow(clippy::too_many_arguments)]
189
197
  pub(super) fn do_on_congestion_event(
190
- &mut self, prior_in_flight: usize, event_time: Instant,
191
- acked_packets: &[Acked], lost_packets: &[Lost],
198
+ &mut self,
199
+ prior_in_flight: usize,
200
+ event_time: Instant,
201
+ acked_packets: &[Acked],
202
+ lost_packets: &[Lost],
192
203
  congestion_event: &mut BBRv2CongestionEvent,
193
- target_bytes_inflight: usize, params: &Params,
194
- recovery_stats: &mut RecoveryStats, cwnd: usize,
204
+ target_bytes_inflight: usize,
205
+ params: &Params,
206
+ recovery_stats: &mut RecoveryStats,
207
+ cwnd: usize,
195
208
  ) -> bool {
196
209
  let mode_before = std::mem::discriminant(self);
197
210
 
@@ -213,13 +226,12 @@ impl Mode {
213
226
  }
214
227
 
215
228
  pub(super) fn do_on_exit_quiescence(
216
- &mut self, now: Instant, quiescence_start_time: Instant, params: &Params,
229
+ &mut self,
230
+ now: Instant,
231
+ quiescence_start_time: Instant,
232
+ params: &Params,
217
233
  ) {
218
- *self = std::mem::take(self).on_exit_quiescence(
219
- now,
220
- quiescence_start_time,
221
- params,
222
- )
234
+ *self = std::mem::take(self).on_exit_quiescence(now, quiescence_start_time, params)
223
235
  }
224
236
 
225
237
  pub fn network_model(&self) -> &BBRv2NetworkModel {
@@ -252,9 +264,7 @@ impl ModeImpl for Placeholder {
252
264
  unreachable!()
253
265
  }
254
266
 
255
- fn enter(
256
- &mut self, _: Instant, _: Option<&BBRv2CongestionEvent>, _params: &Params,
257
- ) {
267
+ fn enter(&mut self, _: Instant, _: Option<&BBRv2CongestionEvent>, _params: &Params) {
258
268
  unreachable!()
259
269
  }
260
270
 
@@ -267,9 +277,16 @@ impl ModeImpl for Placeholder {
267
277
  }
268
278
 
269
279
  fn on_congestion_event(
270
- self, _: usize, _: Instant, _: &[Acked], _: &[Lost],
271
- _: &mut BBRv2CongestionEvent, _: usize, _params: &Params,
272
- _recovery_stats: &mut RecoveryStats, _cwnd: usize,
280
+ self,
281
+ _: usize,
282
+ _: Instant,
283
+ _: &[Acked],
284
+ _: &[Lost],
285
+ _: &mut BBRv2CongestionEvent,
286
+ _: usize,
287
+ _params: &Params,
288
+ _recovery_stats: &mut RecoveryStats,
289
+ _cwnd: usize,
273
290
  ) -> Mode {
274
291
  unreachable!()
275
292
  }
@@ -278,9 +295,7 @@ impl ModeImpl for Placeholder {
278
295
  unreachable!()
279
296
  }
280
297
 
281
- fn on_exit_quiescence(
282
- self, _: Instant, _: Instant, _params: &Params,
283
- ) -> Mode {
298
+ fn on_exit_quiescence(self, _: Instant, _: Instant, _params: &Params) -> Mode {
284
299
  unreachable!()
285
300
  }
286
301
  }