mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
fix: don't use public rid accessors in internal APIs (#22091)
Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
This commit is contained in:
parent
a4e64fb7da
commit
174bb70eda
4 changed files with 23 additions and 5 deletions
|
@ -33,6 +33,7 @@ const {
|
|||
PromisePrototypeCatch,
|
||||
PromisePrototypeThen,
|
||||
Symbol,
|
||||
SymbolFor,
|
||||
TypeError,
|
||||
TypedArrayPrototypeGetSymbolToStringTag,
|
||||
Uint8Array,
|
||||
|
@ -617,7 +618,7 @@ function serve(arg1, arg2) {
|
|||
function serveHttpOnListener(listener, signal, handler, onError, onListen) {
|
||||
const context = new CallbackContext(
|
||||
signal,
|
||||
op_http_serve(listener.rid),
|
||||
op_http_serve(listener[SymbolFor("Deno.internal.rid")]),
|
||||
listener,
|
||||
);
|
||||
const callback = mapToCallback(context, handler, onError);
|
||||
|
@ -633,7 +634,7 @@ function serveHttpOnListener(listener, signal, handler, onError, onListen) {
|
|||
function serveHttpOnConnection(connection, signal, handler, onError, onListen) {
|
||||
const context = new CallbackContext(
|
||||
signal,
|
||||
op_http_serve_on(connection.rid),
|
||||
op_http_serve_on(connection[SymbolFor("Deno.internal.rid")]),
|
||||
null,
|
||||
);
|
||||
const callback = mapToCallback(context, handler, onError);
|
||||
|
|
|
@ -40,6 +40,7 @@ const {
|
|||
SetPrototypeForEach,
|
||||
SymbolAsyncIterator,
|
||||
Symbol,
|
||||
SymbolFor,
|
||||
TypeError,
|
||||
TypedArrayPrototypeSubarray,
|
||||
Uint8Array,
|
||||
|
@ -90,6 +91,7 @@ async function resolveDns(query, recordType, options) {
|
|||
}
|
||||
|
||||
class Conn {
|
||||
[SymbolFor("Deno.internal.rid")] = 0;
|
||||
#rid = 0;
|
||||
#remoteAddr = null;
|
||||
#localAddr = null;
|
||||
|
@ -100,6 +102,7 @@ class Conn {
|
|||
#writable;
|
||||
|
||||
constructor(rid, remoteAddr, localAddr) {
|
||||
this[SymbolFor("Deno.internal.rid")] = rid;
|
||||
this.#rid = rid;
|
||||
this.#remoteAddr = remoteAddr;
|
||||
this.#localAddr = localAddr;
|
||||
|
@ -198,10 +201,12 @@ class Conn {
|
|||
}
|
||||
|
||||
class TcpConn extends Conn {
|
||||
[SymbolFor("Deno.internal.rid")] = 0;
|
||||
#rid = 0;
|
||||
|
||||
constructor(rid, remoteAddr, localAddr) {
|
||||
super(rid, remoteAddr, localAddr);
|
||||
this[SymbolFor("Deno.internal.rid")] = rid;
|
||||
this.#rid = rid;
|
||||
}
|
||||
|
||||
|
@ -224,10 +229,12 @@ class TcpConn extends Conn {
|
|||
}
|
||||
|
||||
class UnixConn extends Conn {
|
||||
[SymbolFor("Deno.internal.rid")] = 0;
|
||||
#rid = 0;
|
||||
|
||||
constructor(rid, remoteAddr, localAddr) {
|
||||
super(rid, remoteAddr, localAddr);
|
||||
this[SymbolFor("Deno.internal.rid")] = rid;
|
||||
this.#rid = rid;
|
||||
}
|
||||
|
||||
|
@ -242,12 +249,14 @@ class UnixConn extends Conn {
|
|||
}
|
||||
|
||||
class Listener {
|
||||
[SymbolFor("Deno.internal.rid")] = 0;
|
||||
#rid = 0;
|
||||
#addr = null;
|
||||
#unref = false;
|
||||
#promise = null;
|
||||
|
||||
constructor(rid, addr) {
|
||||
this[SymbolFor("Deno.internal.rid")] = rid;
|
||||
this.#rid = rid;
|
||||
this.#addr = addr;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ const {
|
|||
} = core.ensureFastOps();
|
||||
const {
|
||||
Number,
|
||||
SymbolFor,
|
||||
TypeError,
|
||||
} = primordials;
|
||||
|
||||
|
@ -24,10 +25,12 @@ function opTlsHandshake(rid) {
|
|||
}
|
||||
|
||||
class TlsConn extends Conn {
|
||||
[SymbolFor("Deno.internal.rid")] = 0;
|
||||
#rid = 0;
|
||||
|
||||
constructor(rid, remoteAddr, localAddr) {
|
||||
super(rid, remoteAddr, localAddr);
|
||||
this[SymbolFor("Deno.internal.rid")] = rid;
|
||||
this.#rid = rid;
|
||||
}
|
||||
|
||||
|
@ -75,10 +78,12 @@ async function connectTls({
|
|||
}
|
||||
|
||||
class TlsListener extends Listener {
|
||||
[SymbolFor("Deno.internal.rid")] = 0;
|
||||
#rid = 0;
|
||||
|
||||
constructor(rid, addr) {
|
||||
super(rid, addr);
|
||||
this[SymbolFor("Deno.internal.rid")] = rid;
|
||||
this.#rid = rid;
|
||||
}
|
||||
|
||||
|
@ -146,7 +151,7 @@ async function startTls(
|
|||
} = {},
|
||||
) {
|
||||
const { 0: rid, 1: localAddr, 2: remoteAddr } = await opStartTls({
|
||||
rid: conn.rid,
|
||||
rid: conn[SymbolFor("Deno.internal.rid")],
|
||||
hostname,
|
||||
certFile,
|
||||
caCerts,
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
import { core, internals } from "ext:core/mod.js";
|
||||
import { core, internals, primordials } from "ext:core/mod.js";
|
||||
const {
|
||||
op_http_start,
|
||||
} = core.ensureFastOps();
|
||||
const {
|
||||
SymbolFor,
|
||||
} = primordials;
|
||||
|
||||
import { HttpConn } from "ext:deno_http/01_http.js";
|
||||
|
||||
|
@ -12,7 +15,7 @@ function serveHttp(conn) {
|
|||
new Error().stack,
|
||||
"Use `Deno.serve()` instead.",
|
||||
);
|
||||
const rid = op_http_start(conn.rid);
|
||||
const rid = op_http_start(conn[SymbolFor("Deno.internal.rid")]);
|
||||
return new HttpConn(rid, conn.remoteAddr, conn.localAddr);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue