mirror of
https://github.com/denoland/deno.git
synced 2024-11-25 15:29:32 -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,
|
PromisePrototypeCatch,
|
||||||
PromisePrototypeThen,
|
PromisePrototypeThen,
|
||||||
Symbol,
|
Symbol,
|
||||||
|
SymbolFor,
|
||||||
TypeError,
|
TypeError,
|
||||||
TypedArrayPrototypeGetSymbolToStringTag,
|
TypedArrayPrototypeGetSymbolToStringTag,
|
||||||
Uint8Array,
|
Uint8Array,
|
||||||
|
@ -617,7 +618,7 @@ function serve(arg1, arg2) {
|
||||||
function serveHttpOnListener(listener, signal, handler, onError, onListen) {
|
function serveHttpOnListener(listener, signal, handler, onError, onListen) {
|
||||||
const context = new CallbackContext(
|
const context = new CallbackContext(
|
||||||
signal,
|
signal,
|
||||||
op_http_serve(listener.rid),
|
op_http_serve(listener[SymbolFor("Deno.internal.rid")]),
|
||||||
listener,
|
listener,
|
||||||
);
|
);
|
||||||
const callback = mapToCallback(context, handler, onError);
|
const callback = mapToCallback(context, handler, onError);
|
||||||
|
@ -633,7 +634,7 @@ function serveHttpOnListener(listener, signal, handler, onError, onListen) {
|
||||||
function serveHttpOnConnection(connection, signal, handler, onError, onListen) {
|
function serveHttpOnConnection(connection, signal, handler, onError, onListen) {
|
||||||
const context = new CallbackContext(
|
const context = new CallbackContext(
|
||||||
signal,
|
signal,
|
||||||
op_http_serve_on(connection.rid),
|
op_http_serve_on(connection[SymbolFor("Deno.internal.rid")]),
|
||||||
null,
|
null,
|
||||||
);
|
);
|
||||||
const callback = mapToCallback(context, handler, onError);
|
const callback = mapToCallback(context, handler, onError);
|
||||||
|
|
|
@ -40,6 +40,7 @@ const {
|
||||||
SetPrototypeForEach,
|
SetPrototypeForEach,
|
||||||
SymbolAsyncIterator,
|
SymbolAsyncIterator,
|
||||||
Symbol,
|
Symbol,
|
||||||
|
SymbolFor,
|
||||||
TypeError,
|
TypeError,
|
||||||
TypedArrayPrototypeSubarray,
|
TypedArrayPrototypeSubarray,
|
||||||
Uint8Array,
|
Uint8Array,
|
||||||
|
@ -90,6 +91,7 @@ async function resolveDns(query, recordType, options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
class Conn {
|
class Conn {
|
||||||
|
[SymbolFor("Deno.internal.rid")] = 0;
|
||||||
#rid = 0;
|
#rid = 0;
|
||||||
#remoteAddr = null;
|
#remoteAddr = null;
|
||||||
#localAddr = null;
|
#localAddr = null;
|
||||||
|
@ -100,6 +102,7 @@ class Conn {
|
||||||
#writable;
|
#writable;
|
||||||
|
|
||||||
constructor(rid, remoteAddr, localAddr) {
|
constructor(rid, remoteAddr, localAddr) {
|
||||||
|
this[SymbolFor("Deno.internal.rid")] = rid;
|
||||||
this.#rid = rid;
|
this.#rid = rid;
|
||||||
this.#remoteAddr = remoteAddr;
|
this.#remoteAddr = remoteAddr;
|
||||||
this.#localAddr = localAddr;
|
this.#localAddr = localAddr;
|
||||||
|
@ -198,10 +201,12 @@ class Conn {
|
||||||
}
|
}
|
||||||
|
|
||||||
class TcpConn extends Conn {
|
class TcpConn extends Conn {
|
||||||
|
[SymbolFor("Deno.internal.rid")] = 0;
|
||||||
#rid = 0;
|
#rid = 0;
|
||||||
|
|
||||||
constructor(rid, remoteAddr, localAddr) {
|
constructor(rid, remoteAddr, localAddr) {
|
||||||
super(rid, remoteAddr, localAddr);
|
super(rid, remoteAddr, localAddr);
|
||||||
|
this[SymbolFor("Deno.internal.rid")] = rid;
|
||||||
this.#rid = rid;
|
this.#rid = rid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,10 +229,12 @@ class TcpConn extends Conn {
|
||||||
}
|
}
|
||||||
|
|
||||||
class UnixConn extends Conn {
|
class UnixConn extends Conn {
|
||||||
|
[SymbolFor("Deno.internal.rid")] = 0;
|
||||||
#rid = 0;
|
#rid = 0;
|
||||||
|
|
||||||
constructor(rid, remoteAddr, localAddr) {
|
constructor(rid, remoteAddr, localAddr) {
|
||||||
super(rid, remoteAddr, localAddr);
|
super(rid, remoteAddr, localAddr);
|
||||||
|
this[SymbolFor("Deno.internal.rid")] = rid;
|
||||||
this.#rid = rid;
|
this.#rid = rid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,12 +249,14 @@ class UnixConn extends Conn {
|
||||||
}
|
}
|
||||||
|
|
||||||
class Listener {
|
class Listener {
|
||||||
|
[SymbolFor("Deno.internal.rid")] = 0;
|
||||||
#rid = 0;
|
#rid = 0;
|
||||||
#addr = null;
|
#addr = null;
|
||||||
#unref = false;
|
#unref = false;
|
||||||
#promise = null;
|
#promise = null;
|
||||||
|
|
||||||
constructor(rid, addr) {
|
constructor(rid, addr) {
|
||||||
|
this[SymbolFor("Deno.internal.rid")] = rid;
|
||||||
this.#rid = rid;
|
this.#rid = rid;
|
||||||
this.#addr = addr;
|
this.#addr = addr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ const {
|
||||||
} = core.ensureFastOps();
|
} = core.ensureFastOps();
|
||||||
const {
|
const {
|
||||||
Number,
|
Number,
|
||||||
|
SymbolFor,
|
||||||
TypeError,
|
TypeError,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
|
@ -24,10 +25,12 @@ function opTlsHandshake(rid) {
|
||||||
}
|
}
|
||||||
|
|
||||||
class TlsConn extends Conn {
|
class TlsConn extends Conn {
|
||||||
|
[SymbolFor("Deno.internal.rid")] = 0;
|
||||||
#rid = 0;
|
#rid = 0;
|
||||||
|
|
||||||
constructor(rid, remoteAddr, localAddr) {
|
constructor(rid, remoteAddr, localAddr) {
|
||||||
super(rid, remoteAddr, localAddr);
|
super(rid, remoteAddr, localAddr);
|
||||||
|
this[SymbolFor("Deno.internal.rid")] = rid;
|
||||||
this.#rid = rid;
|
this.#rid = rid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,10 +78,12 @@ async function connectTls({
|
||||||
}
|
}
|
||||||
|
|
||||||
class TlsListener extends Listener {
|
class TlsListener extends Listener {
|
||||||
|
[SymbolFor("Deno.internal.rid")] = 0;
|
||||||
#rid = 0;
|
#rid = 0;
|
||||||
|
|
||||||
constructor(rid, addr) {
|
constructor(rid, addr) {
|
||||||
super(rid, addr);
|
super(rid, addr);
|
||||||
|
this[SymbolFor("Deno.internal.rid")] = rid;
|
||||||
this.#rid = rid;
|
this.#rid = rid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +151,7 @@ async function startTls(
|
||||||
} = {},
|
} = {},
|
||||||
) {
|
) {
|
||||||
const { 0: rid, 1: localAddr, 2: remoteAddr } = await opStartTls({
|
const { 0: rid, 1: localAddr, 2: remoteAddr } = await opStartTls({
|
||||||
rid: conn.rid,
|
rid: conn[SymbolFor("Deno.internal.rid")],
|
||||||
hostname,
|
hostname,
|
||||||
certFile,
|
certFile,
|
||||||
caCerts,
|
caCerts,
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
// 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 {
|
const {
|
||||||
op_http_start,
|
op_http_start,
|
||||||
} = core.ensureFastOps();
|
} = core.ensureFastOps();
|
||||||
|
const {
|
||||||
|
SymbolFor,
|
||||||
|
} = primordials;
|
||||||
|
|
||||||
import { HttpConn } from "ext:deno_http/01_http.js";
|
import { HttpConn } from "ext:deno_http/01_http.js";
|
||||||
|
|
||||||
|
@ -12,7 +15,7 @@ function serveHttp(conn) {
|
||||||
new Error().stack,
|
new Error().stack,
|
||||||
"Use `Deno.serve()` instead.",
|
"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);
|
return new HttpConn(rid, conn.remoteAddr, conn.localAddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue