rwebtransport 0.2.3 → 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 (96) hide show
  1. package/Cargo.lock +153 -226
  2. package/Cargo.toml +5 -5
  3. package/README.md +4 -4
  4. package/crates/echo-server/src/bin/gen-test-cert.rs +1 -1
  5. package/crates/native/Cargo.toml +1 -1
  6. package/crates/native/src/config.rs +13 -1
  7. package/crates/native/src/driver.rs +249 -91
  8. package/crates/native/src/lib.rs +9 -10
  9. package/crates/native/src/parser_memory.rs +1 -0
  10. package/crates/native/src/server.rs +197 -182
  11. package/crates/native/src/session.rs +329 -177
  12. package/crates/native/src/test_support.rs +2 -2
  13. package/crates/wtcore/src/h3.rs +166 -10
  14. package/dist/index.js +92 -45
  15. package/dist/index.js.map +2 -2
  16. package/dist/index.mjs +92 -45
  17. package/dist/index.mjs.map +2 -2
  18. package/dist/native.d.ts +9 -4
  19. package/package.json +14 -11
  20. package/prebuilds/darwin-arm64/rwebtransport.node +0 -0
  21. package/prebuilds/linux-arm64/rwebtransport.node +0 -0
  22. package/prebuilds/linux-x64/rwebtransport.node +0 -0
  23. package/prebuilds/win32-x64/rwebtransport.node +0 -0
  24. package/scripts/build-linux-prebuilt.sh +46 -0
  25. package/scripts/build.js +10 -3
  26. package/vendor/quiche/AGENTS.md +10 -0
  27. package/vendor/quiche/Cargo.lock +239 -248
  28. package/vendor/quiche/Cargo.toml +23 -10
  29. package/vendor/quiche/examples/Makefile +4 -4
  30. package/vendor/quiche/examples/client.rs +10 -28
  31. package/vendor/quiche/examples/http3-client.rs +20 -34
  32. package/vendor/quiche/examples/http3-server.rs +47 -78
  33. package/vendor/quiche/examples/server.rs +19 -49
  34. package/vendor/quiche/include/quiche.h +35 -4
  35. package/vendor/quiche/src/build.rs +17 -0
  36. package/vendor/quiche/src/cid.rs +129 -61
  37. package/vendor/quiche/src/crypto/boringssl.rs +98 -86
  38. package/vendor/quiche/src/crypto/mod.rs +64 -77
  39. package/vendor/quiche/src/dgram.rs +2 -3
  40. package/vendor/quiche/src/error.rs +22 -20
  41. package/vendor/quiche/src/ffi.rs +558 -280
  42. package/vendor/quiche/src/flowcontrol.rs +0 -7
  43. package/vendor/quiche/src/frame.rs +134 -135
  44. package/vendor/quiche/src/h3/ffi.rs +73 -60
  45. package/vendor/quiche/src/h3/frame.rs +70 -90
  46. package/vendor/quiche/src/h3/mod.rs +1024 -593
  47. package/vendor/quiche/src/h3/qpack/decoder.rs +248 -34
  48. package/vendor/quiche/src/h3/qpack/dynamic_table.rs +859 -0
  49. package/vendor/quiche/src/h3/qpack/encoder.rs +14 -17
  50. package/vendor/quiche/src/h3/qpack/mod.rs +48 -0
  51. package/vendor/quiche/src/h3/qpack/static_table.rs +86 -73
  52. package/vendor/quiche/src/h3/stream.rs +1009 -194
  53. package/vendor/quiche/src/lib.rs +1346 -1195
  54. package/vendor/quiche/src/minmax.rs +2 -6
  55. package/vendor/quiche/src/packet.rs +420 -552
  56. package/vendor/quiche/src/path.rs +202 -72
  57. package/vendor/quiche/src/pmtud.rs +18 -16
  58. package/vendor/quiche/src/ranges.rs +184 -82
  59. package/vendor/quiche/src/recovery/AGENTS.md +5 -2
  60. package/vendor/quiche/src/recovery/bandwidth.rs +59 -40
  61. package/vendor/quiche/src/recovery/bytes_in_flight.rs +2 -2
  62. package/vendor/quiche/src/recovery/congestion/cubic.rs +38 -47
  63. package/vendor/quiche/src/recovery/congestion/delivery_rate.rs +54 -60
  64. package/vendor/quiche/src/recovery/congestion/hystart.rs +6 -10
  65. package/vendor/quiche/src/recovery/congestion/mod.rs +110 -42
  66. package/vendor/quiche/src/recovery/congestion/prr.rs +4 -1
  67. package/vendor/quiche/src/recovery/congestion/recovery.rs +91 -95
  68. package/vendor/quiche/src/recovery/congestion/reno.rs +17 -12
  69. package/vendor/quiche/src/recovery/congestion/test_sender.rs +8 -27
  70. package/vendor/quiche/src/recovery/gcongestion/bbr/bandwidth_sampler.rs +159 -247
  71. package/vendor/quiche/src/recovery/gcongestion/bbr/windowed_filter.rs +9 -14
  72. package/vendor/quiche/src/recovery/gcongestion/bbr2/drain.rs +18 -15
  73. package/vendor/quiche/src/recovery/gcongestion/bbr2/mode.rs +43 -28
  74. package/vendor/quiche/src/recovery/gcongestion/bbr2/network_model.rs +349 -76
  75. package/vendor/quiche/src/recovery/gcongestion/bbr2/probe_bw.rs +147 -195
  76. package/vendor/quiche/src/recovery/gcongestion/bbr2/probe_rtt.rs +29 -27
  77. package/vendor/quiche/src/recovery/gcongestion/bbr2/rtt_jump_detector/global_min.rs +180 -0
  78. package/vendor/quiche/src/recovery/gcongestion/bbr2/rtt_jump_detector/global_min_tests.rs +221 -0
  79. package/vendor/quiche/src/recovery/gcongestion/bbr2/rtt_jump_detector/hmm.rs +395 -0
  80. package/vendor/quiche/src/recovery/gcongestion/bbr2/rtt_jump_detector/hmm_tests.rs +473 -0
  81. package/vendor/quiche/src/recovery/gcongestion/bbr2/rtt_jump_detector/mod.rs +175 -0
  82. package/vendor/quiche/src/recovery/gcongestion/bbr2/startup.rs +33 -26
  83. package/vendor/quiche/src/recovery/gcongestion/bbr2.rs +107 -60
  84. package/vendor/quiche/src/recovery/gcongestion/mod.rs +64 -11
  85. package/vendor/quiche/src/recovery/gcongestion/pacer.rs +34 -25
  86. package/vendor/quiche/src/recovery/gcongestion/recovery.rs +81 -86
  87. package/vendor/quiche/src/recovery/mod.rs +414 -173
  88. package/vendor/quiche/src/recovery/rtt.rs +8 -5
  89. package/vendor/quiche/src/stream/mod.rs +864 -133
  90. package/vendor/quiche/src/stream/recv_buf.rs +471 -172
  91. package/vendor/quiche/src/stream/send_buf.rs +338 -81
  92. package/vendor/quiche/src/test_utils.rs +78 -64
  93. package/vendor/quiche/src/tests.rs +2559 -1335
  94. package/vendor/quiche/src/tls/boringssl.rs +60 -63
  95. package/vendor/quiche/src/tls/mod.rs +146 -193
  96. package/vendor/quiche/src/transport_params.rs +87 -103
@@ -42,9 +42,7 @@ pub(super) struct SSL_QUIC_METHOD {
42
42
 
43
43
  flush_flight: Option<extern "C" fn(ssl: *mut SSL) -> c_int>,
44
44
 
45
- send_alert: Option<
46
- extern "C" fn(ssl: *mut SSL, level: crypto::Level, alert: u8) -> c_int,
47
- >,
45
+ send_alert: Option<extern "C" fn(ssl: *mut SSL, level: crypto::Level, alert: u8) -> c_int>,
48
46
  }
49
47
 
50
48
  #[cfg(test)]
@@ -95,10 +93,7 @@ pub(super) static QUICHE_STREAM_METHOD: SSL_QUIC_METHOD = SSL_QUIC_METHOD {
95
93
  impl Context {
96
94
  pub fn set_early_data_enabled(&mut self, _enabled: bool) {
97
95
  unsafe {
98
- SSL_CTX_set_early_data_enabled(
99
- self.as_mut_ptr(),
100
- i32::from(_enabled),
101
- );
96
+ SSL_CTX_set_early_data_enabled(self.as_mut_ptr(), i32::from(_enabled));
102
97
  }
103
98
  }
104
99
  }
@@ -106,11 +101,7 @@ impl Context {
106
101
  impl Handshake {
107
102
  pub fn set_quic_early_data_context(&mut self, context: &[u8]) -> Result<()> {
108
103
  map_result(unsafe {
109
- SSL_set_quic_early_data_context(
110
- self.as_mut_ptr(),
111
- context.as_ptr(),
112
- context.len(),
113
- )
104
+ SSL_set_quic_early_data_context(self.as_mut_ptr(), context.as_ptr(), context.len())
114
105
  })
115
106
  }
116
107
 
@@ -122,8 +113,7 @@ impl Handshake {
122
113
  return Err(Error::TlsFail);
123
114
  }
124
115
 
125
- let session =
126
- SSL_SESSION_from_bytes(session.as_ptr(), session.len(), ctx);
116
+ let session = SSL_SESSION_from_bytes(session.as_ptr(), session.len(), ctx);
127
117
 
128
118
  if session.is_null() {
129
119
  return Err(Error::TlsFail);
@@ -178,8 +168,7 @@ impl Handshake {
178
168
 
179
169
  pub fn peer_cert_chain(&self) -> Option<Vec<&[u8]>> {
180
170
  let cert_chain = unsafe {
181
- let chain =
182
- map_result_ptr(SSL_get0_peer_certificates(self.as_ptr())).ok()?;
171
+ let chain = map_result_ptr(SSL_get0_peer_certificates(self.as_ptr())).ok()?;
183
172
 
184
173
  let num = sk_num(chain);
185
174
  if num == 0 {
@@ -188,9 +177,7 @@ impl Handshake {
188
177
 
189
178
  let mut cert_chain = vec![];
190
179
  for i in 0..num {
191
- let buffer =
192
- map_result_ptr(sk_value(chain, i) as *const CRYPTO_BUFFER)
193
- .ok()?;
180
+ let buffer = map_result_ptr(sk_value(chain, i) as *const CRYPTO_BUFFER).ok()?;
194
181
 
195
182
  let out_len = CRYPTO_BUFFER_len(buffer);
196
183
  if out_len == 0 {
@@ -211,15 +198,12 @@ impl Handshake {
211
198
 
212
199
  pub fn peer_cert(&self) -> Option<&[u8]> {
213
200
  let peer_cert = unsafe {
214
- let chain =
215
- map_result_ptr(SSL_get0_peer_certificates(self.as_ptr())).ok()?;
201
+ let chain = map_result_ptr(SSL_get0_peer_certificates(self.as_ptr())).ok()?;
216
202
  if sk_num(chain) == 0 {
217
203
  return None;
218
204
  }
219
205
 
220
- let buffer =
221
- map_result_ptr(sk_value(chain, 0) as *const CRYPTO_BUFFER)
222
- .ok()?;
206
+ let buffer = map_result_ptr(sk_value(chain, 0) as *const CRYPTO_BUFFER).ok()?;
223
207
 
224
208
  let out_len = CRYPTO_BUFFER_len(buffer);
225
209
  if out_len == 0 {
@@ -237,37 +221,45 @@ impl Handshake {
237
221
  #[cfg(test)]
238
222
  pub fn set_failing_private_key_method(&mut self) {
239
223
  extern "C" fn failing_sign(
240
- _ssl: *mut SSL, _out: *mut u8, _out_len: *mut usize, _max_out: usize,
241
- _signature_algorithm: u16, _in: *const u8, _in_len: usize,
224
+ _ssl: *mut SSL,
225
+ _out: *mut u8,
226
+ _out_len: *mut usize,
227
+ _max_out: usize,
228
+ _signature_algorithm: u16,
229
+ _in: *const u8,
230
+ _in_len: usize,
242
231
  ) -> ssl_private_key_result_t {
243
232
  ssl_private_key_result_t::ssl_private_key_failure
244
233
  }
245
234
 
246
235
  extern "C" fn failing_decrypt(
247
- _ssl: *mut SSL, _out: *mut u8, _out_len: *mut usize, _max_out: usize,
248
- _in: *const u8, _in_len: usize,
236
+ _ssl: *mut SSL,
237
+ _out: *mut u8,
238
+ _out_len: *mut usize,
239
+ _max_out: usize,
240
+ _in: *const u8,
241
+ _in_len: usize,
249
242
  ) -> ssl_private_key_result_t {
250
243
  ssl_private_key_result_t::ssl_private_key_failure
251
244
  }
252
245
 
253
246
  extern "C" fn failing_complete(
254
- _ssl: *mut SSL, _out: *mut u8, _out_len: *mut usize, _max_out: usize,
247
+ _ssl: *mut SSL,
248
+ _out: *mut u8,
249
+ _out_len: *mut usize,
250
+ _max_out: usize,
255
251
  ) -> ssl_private_key_result_t {
256
252
  ssl_private_key_result_t::ssl_private_key_failure
257
253
  }
258
254
 
259
- static QUICHE_PRIVATE_KEY_METHOD: SSL_PRIVATE_KEY_METHOD =
260
- SSL_PRIVATE_KEY_METHOD {
261
- decrypt: Some(failing_decrypt),
262
- sign: Some(failing_sign),
263
- complete: Some(failing_complete),
264
- };
255
+ static QUICHE_PRIVATE_KEY_METHOD: SSL_PRIVATE_KEY_METHOD = SSL_PRIVATE_KEY_METHOD {
256
+ decrypt: Some(failing_decrypt),
257
+ sign: Some(failing_sign),
258
+ complete: Some(failing_complete),
259
+ };
265
260
 
266
261
  unsafe {
267
- SSL_set_private_key_method(
268
- self.as_mut_ptr(),
269
- &QUICHE_PRIVATE_KEY_METHOD,
270
- );
262
+ SSL_set_private_key_method(self.as_mut_ptr(), &QUICHE_PRIVATE_KEY_METHOD);
271
263
  }
272
264
  }
273
265
 
@@ -276,8 +268,7 @@ impl Handshake {
276
268
  }
277
269
 
278
270
  pub fn early_data_reason(&self) -> u32 {
279
- let reuse_reason_status =
280
- unsafe { SSL_get_early_data_reason(self.as_ptr()) };
271
+ let reuse_reason_status = unsafe { SSL_get_early_data_reason(self.as_ptr()) };
281
272
  reuse_reason_status.0
282
273
  }
283
274
  }
@@ -306,46 +297,48 @@ pub struct ssl_early_data_reason_t(pub ::std::os::raw::c_uint);
306
297
  extern "C" {
307
298
  // SSL_METHOD specific for boringssl.
308
299
  pub(super) fn SSL_CTX_set_tlsext_ticket_keys(
309
- ctx: *mut SSL_CTX, key: *const u8, key_len: usize,
300
+ ctx: *mut SSL_CTX,
301
+ key: *const u8,
302
+ key_len: usize,
310
303
  ) -> c_int;
311
304
  fn SSL_CTX_set_early_data_enabled(ctx: *mut SSL_CTX, enabled: i32);
312
305
 
313
- pub(super) fn SSL_CTX_set_session_cache_mode(
314
- ctx: *mut SSL_CTX, mode: c_int,
315
- ) -> c_int;
306
+ // BoringSSL exports `SSL_CTX_set1_groups_list` as a real symbol; on
307
+ // OpenSSL it is a header macro. See `openssl_quictls.rs` for the
308
+ // OpenSSL shim.
309
+ pub(super) fn SSL_CTX_set1_groups_list(ctx: *mut SSL_CTX, groups: *const c_char) -> c_int;
310
+
311
+ pub(super) fn SSL_CTX_set_session_cache_mode(ctx: *mut SSL_CTX, mode: c_int) -> c_int;
316
312
  pub(super) fn SSL_get_ex_new_index(
317
- argl: c_long, argp: *const c_void, unused: *const c_void,
318
- dup_unused: *const c_void, free_func: *const c_void,
313
+ argl: c_long,
314
+ argp: *const c_void,
315
+ unused: *const c_void,
316
+ dup_unused: *const c_void,
317
+ free_func: *const c_void,
319
318
  ) -> c_int;
320
319
 
321
320
  fn SSL_get_curve_id(ssl: *const SSL) -> u16;
322
321
  fn SSL_get_curve_name(curve: u16) -> *const c_char;
323
322
 
324
323
  fn SSL_get_peer_signature_algorithm(ssl: *const SSL) -> u16;
325
- fn SSL_get_signature_algorithm_name(
326
- sigalg: u16, include_curve: i32,
327
- ) -> *const c_char;
324
+ fn SSL_get_signature_algorithm_name(sigalg: u16, include_curve: i32) -> *const c_char;
328
325
 
329
326
  fn SSL_get0_peer_certificates(ssl: *const SSL) -> *const STACK_OF;
330
327
 
331
- pub(super) fn SSL_set_min_proto_version(ssl: *mut SSL, version: u16)
332
- -> c_int;
328
+ pub(super) fn SSL_set_min_proto_version(ssl: *mut SSL, version: u16) -> c_int;
333
329
 
334
- pub(super) fn SSL_set_max_proto_version(ssl: *mut SSL, version: u16)
335
- -> c_int;
330
+ pub(super) fn SSL_set_max_proto_version(ssl: *mut SSL, version: u16) -> c_int;
336
331
 
337
- pub(super) fn SSL_set_tlsext_host_name(
338
- ssl: *mut SSL, name: *const c_char,
339
- ) -> c_int;
332
+ pub(super) fn SSL_set_tlsext_host_name(ssl: *mut SSL, name: *const c_char) -> c_int;
340
333
 
341
334
  fn SSL_set_quic_early_data_context(
342
- ssl: *mut SSL, context: *const u8, context_len: usize,
335
+ ssl: *mut SSL,
336
+ context: *const u8,
337
+ context_len: usize,
343
338
  ) -> c_int;
344
339
 
345
340
  #[cfg(test)]
346
- fn SSL_set_private_key_method(
347
- ssl: *mut SSL, key_method: *const SSL_PRIVATE_KEY_METHOD,
348
- );
341
+ fn SSL_set_private_key_method(ssl: *mut SSL, key_method: *const SSL_PRIVATE_KEY_METHOD);
349
342
 
350
343
  fn SSL_reset_early_data_reject(ssl: *mut SSL);
351
344
 
@@ -354,11 +347,15 @@ extern "C" {
354
347
  fn SSL_get_early_data_reason(ssl: *const SSL) -> ssl_early_data_reason_t;
355
348
 
356
349
  fn SSL_SESSION_to_bytes(
357
- session: *const SSL_SESSION, out: *mut *mut u8, out_len: *mut usize,
350
+ session: *const SSL_SESSION,
351
+ out: *mut *mut u8,
352
+ out_len: *mut usize,
358
353
  ) -> c_int;
359
354
 
360
355
  fn SSL_SESSION_from_bytes(
361
- input: *const u8, input_len: usize, ctx: *const SSL_CTX,
356
+ input: *const u8,
357
+ input_len: usize,
358
+ ctx: *const SSL_CTX,
362
359
  ) -> *mut SSL_SESSION;
363
360
 
364
361
  // STACK_OF