refactor(quic): introduce endpoint, 0rtt, cleanup (#27444)

A QUIC endpoint is a UDP socket which multiplexes QUIC sessions, which
may be initiated in either direction. This PR exposes endpoints and
moves things around as needed.

Now that endpoints can be reused between client connections, we have a
way to share tls tickets between them and allow 0rtt. This interface
currently works by conditionally returning a promise.

Also cleaned up the rust op names, fixed some lingering problems in the
data transmission, and switched to explicit error types.
This commit is contained in:
snek 2025-01-06 15:24:59 +01:00 committed by GitHub
parent 4b35ba6b13
commit ccd375802a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 1128 additions and 596 deletions

View file

@ -1,6 +1,6 @@
// Copyright 2018-2025 the Deno authors. MIT license.
import { core } from "ext:core/mod.js";
import { core, primordials } from "ext:core/mod.js";
import {
op_net_listen_udp,
op_net_listen_unixpacket,
@ -13,7 +13,6 @@ import * as console from "ext:deno_console/01_console.js";
import * as ffi from "ext:deno_ffi/00_ffi.js";
import * as net from "ext:deno_net/01_net.js";
import * as tls from "ext:deno_net/02_tls.js";
import * as quic from "ext:deno_net/03_quic.js";
import * as serve from "ext:deno_http/00_serve.ts";
import * as http from "ext:deno_http/01_http.js";
import * as websocket from "ext:deno_http/02_websocket.ts";
@ -32,6 +31,10 @@ import * as cron from "ext:deno_cron/01_cron.ts";
import * as webgpuSurface from "ext:deno_webgpu/02_surface.js";
import * as telemetry from "ext:deno_telemetry/telemetry.ts";
const { ObjectDefineProperties } = primordials;
const loadQuic = core.createLazyLoader("ext:deno_net/03_quic.js");
const denoNs = {
Process: process.Process,
run: process.run,
@ -175,17 +178,28 @@ denoNsUnstableById[unstableIds.net] = {
op_net_listen_udp,
op_net_listen_unixpacket,
),
connectQuic: quic.connectQuic,
listenQuic: quic.listenQuic,
QuicBidirectionalStream: quic.QuicBidirectionalStream,
QuicConn: quic.QuicConn,
QuicListener: quic.QuicListener,
QuicReceiveStream: quic.QuicReceiveStream,
QuicSendStream: quic.QuicSendStream,
QuicIncoming: quic.QuicIncoming,
};
ObjectDefineProperties(denoNsUnstableById[unstableIds.net], {
connectQuic: core.propWritableLazyLoaded((q) => q.connectQuic, loadQuic),
QuicEndpoint: core.propWritableLazyLoaded((q) => q.QuicEndpoint, loadQuic),
QuicBidirectionalStream: core.propWritableLazyLoaded(
(q) => q.QuicBidirectionalStream,
loadQuic,
),
QuicConn: core.propWritableLazyLoaded((q) => q.QuicConn, loadQuic),
QuicListener: core.propWritableLazyLoaded((q) => q.QuicListener, loadQuic),
QuicReceiveStream: core.propWritableLazyLoaded(
(q) => q.QuicReceiveStream,
loadQuic,
),
QuicSendStream: core.propWritableLazyLoaded(
(q) => q.QuicSendStream,
loadQuic,
),
QuicIncoming: core.propWritableLazyLoaded((q) => q.QuicIncoming, loadQuic),
});
// denoNsUnstableById[unstableIds.unsafeProto] = { __proto__: null }
denoNsUnstableById[unstableIds.webgpu] = {