mirror of
https://github.com/denoland/deno.git
synced 2024-12-25 16:49:18 -05:00
Fixes #10200 (again) This reverts commit9c7c9a35c1
anda8057e3e06
.
This commit is contained in:
parent
07887b120c
commit
b6203cb465
4 changed files with 26 additions and 50 deletions
36
cli/dts/lib.deno.ns.d.ts
vendored
36
cli/dts/lib.deno.ns.d.ts
vendored
|
@ -1726,44 +1726,40 @@ declare namespace Deno {
|
||||||
* Requires `allow-write` permission. */
|
* Requires `allow-write` permission. */
|
||||||
export function truncate(name: string, len?: number): Promise<void>;
|
export function truncate(name: string, len?: number): Promise<void>;
|
||||||
|
|
||||||
export interface Addr {
|
export interface NetAddr {
|
||||||
transport: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface NetAddr extends Addr {
|
|
||||||
transport: "tcp" | "udp";
|
transport: "tcp" | "udp";
|
||||||
hostname: string;
|
hostname: string;
|
||||||
port: number;
|
port: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UnixAddr extends Addr {
|
export interface UnixAddr {
|
||||||
transport: "unix" | "unixpacket";
|
transport: "unix" | "unixpacket";
|
||||||
path: string;
|
path: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type Addr = NetAddr | UnixAddr;
|
||||||
|
|
||||||
/** A generic network listener for stream-oriented protocols. */
|
/** A generic network listener for stream-oriented protocols. */
|
||||||
export interface Listener<Address extends Addr = Addr>
|
export interface Listener extends AsyncIterable<Conn> {
|
||||||
extends AsyncIterable<Conn<Address>> {
|
|
||||||
/** Waits for and resolves to the next connection to the `Listener`. */
|
/** Waits for and resolves to the next connection to the `Listener`. */
|
||||||
accept(): Promise<Conn<Address>>;
|
accept(): Promise<Conn>;
|
||||||
/** Close closes the listener. Any pending accept promises will be rejected
|
/** Close closes the listener. Any pending accept promises will be rejected
|
||||||
* with errors. */
|
* with errors. */
|
||||||
close(): void;
|
close(): void;
|
||||||
/** Return the address of the `Listener`. */
|
/** Return the address of the `Listener`. */
|
||||||
readonly addr: Address;
|
readonly addr: Addr;
|
||||||
|
|
||||||
/** Return the rid of the `Listener`. */
|
/** Return the rid of the `Listener`. */
|
||||||
readonly rid: number;
|
readonly rid: number;
|
||||||
|
|
||||||
[Symbol.asyncIterator](): AsyncIterableIterator<Conn<Address>>;
|
[Symbol.asyncIterator](): AsyncIterableIterator<Conn>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Conn<Address extends Addr = Addr>
|
export interface Conn extends Reader, Writer, Closer {
|
||||||
extends Reader, Writer, Closer {
|
|
||||||
/** The local address of the connection. */
|
/** The local address of the connection. */
|
||||||
readonly localAddr: Address;
|
readonly localAddr: Addr;
|
||||||
/** The remote address of the connection. */
|
/** The remote address of the connection. */
|
||||||
readonly remoteAddr: Address;
|
readonly remoteAddr: Addr;
|
||||||
/** The resource ID of the connection. */
|
/** The resource ID of the connection. */
|
||||||
readonly rid: number;
|
readonly rid: number;
|
||||||
/** Shuts down (`shutdown(2)`) the write side of the connection. Most
|
/** Shuts down (`shutdown(2)`) the write side of the connection. Most
|
||||||
|
@ -1791,7 +1787,7 @@ declare namespace Deno {
|
||||||
* Requires `allow-net` permission. */
|
* Requires `allow-net` permission. */
|
||||||
export function listen(
|
export function listen(
|
||||||
options: ListenOptions & { transport?: "tcp" },
|
options: ListenOptions & { transport?: "tcp" },
|
||||||
): Listener<NetAddr>;
|
): Listener;
|
||||||
|
|
||||||
export interface ListenTlsOptions extends ListenOptions {
|
export interface ListenTlsOptions extends ListenOptions {
|
||||||
/** Server certificate file. */
|
/** Server certificate file. */
|
||||||
|
@ -1810,7 +1806,7 @@ declare namespace Deno {
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* Requires `allow-net` permission. */
|
* Requires `allow-net` permission. */
|
||||||
export function listenTls(options: ListenTlsOptions): Listener<NetAddr>;
|
export function listenTls(options: ListenTlsOptions): Listener;
|
||||||
|
|
||||||
export interface ConnectOptions {
|
export interface ConnectOptions {
|
||||||
/** The port to connect to. */
|
/** The port to connect to. */
|
||||||
|
@ -1833,7 +1829,7 @@ declare namespace Deno {
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* Requires `allow-net` permission for "tcp". */
|
* Requires `allow-net` permission for "tcp". */
|
||||||
export function connect(options: ConnectOptions): Promise<Conn<NetAddr>>;
|
export function connect(options: ConnectOptions): Promise<Conn>;
|
||||||
|
|
||||||
export interface ConnectTlsOptions {
|
export interface ConnectTlsOptions {
|
||||||
/** The port to connect to. */
|
/** The port to connect to. */
|
||||||
|
@ -1859,9 +1855,7 @@ declare namespace Deno {
|
||||||
*
|
*
|
||||||
* Requires `allow-net` permission.
|
* Requires `allow-net` permission.
|
||||||
*/
|
*/
|
||||||
export function connectTls(
|
export function connectTls(options: ConnectTlsOptions): Promise<Conn>;
|
||||||
options: ConnectTlsOptions,
|
|
||||||
): Promise<Conn<NetAddr>>;
|
|
||||||
|
|
||||||
/** Shutdown socket send operations.
|
/** Shutdown socket send operations.
|
||||||
*
|
*
|
||||||
|
|
28
cli/dts/lib.deno.unstable.d.ts
vendored
28
cli/dts/lib.deno.unstable.d.ts
vendored
|
@ -874,26 +874,23 @@ declare namespace Deno {
|
||||||
/** **UNSTABLE**: new API, yet to be vetted.
|
/** **UNSTABLE**: new API, yet to be vetted.
|
||||||
*
|
*
|
||||||
* A generic transport listener for message-oriented protocols. */
|
* A generic transport listener for message-oriented protocols. */
|
||||||
export interface DatagramConn<Address extends Addr = Addr>
|
export interface DatagramConn extends AsyncIterable<[Uint8Array, Addr]> {
|
||||||
extends AsyncIterable<[Uint8Array, Address]> {
|
|
||||||
/** **UNSTABLE**: new API, yet to be vetted.
|
/** **UNSTABLE**: new API, yet to be vetted.
|
||||||
*
|
*
|
||||||
* Waits for and resolves to the next message to the `UDPConn`. */
|
* Waits for and resolves to the next message to the `UDPConn`. */
|
||||||
receive(p?: Uint8Array): Promise<[Uint8Array, Address]>;
|
receive(p?: Uint8Array): Promise<[Uint8Array, Addr]>;
|
||||||
/** UNSTABLE: new API, yet to be vetted.
|
/** UNSTABLE: new API, yet to be vetted.
|
||||||
*
|
*
|
||||||
* Sends a message to the target. */
|
* Sends a message to the target. */
|
||||||
send(p: Uint8Array, addr: Address): Promise<number>;
|
send(p: Uint8Array, addr: Addr): Promise<number>;
|
||||||
/** UNSTABLE: new API, yet to be vetted.
|
/** UNSTABLE: new API, yet to be vetted.
|
||||||
*
|
*
|
||||||
* Close closes the socket. Any pending message promises will be rejected
|
* Close closes the socket. Any pending message promises will be rejected
|
||||||
* with errors. */
|
* with errors. */
|
||||||
close(): void;
|
close(): void;
|
||||||
/** Return the address of the `UDPConn`. */
|
/** Return the address of the `UDPConn`. */
|
||||||
readonly addr: Address;
|
readonly addr: Addr;
|
||||||
[Symbol.asyncIterator](): AsyncIterableIterator<
|
[Symbol.asyncIterator](): AsyncIterableIterator<[Uint8Array, Addr]>;
|
||||||
[Uint8Array, Address]
|
|
||||||
>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UnixListenOptions {
|
export interface UnixListenOptions {
|
||||||
|
@ -912,7 +909,7 @@ declare namespace Deno {
|
||||||
* Requires `allow-read` and `allow-write` permission. */
|
* Requires `allow-read` and `allow-write` permission. */
|
||||||
export function listen(
|
export function listen(
|
||||||
options: UnixListenOptions & { transport: "unix" },
|
options: UnixListenOptions & { transport: "unix" },
|
||||||
): Listener<UnixAddr>;
|
): Listener;
|
||||||
|
|
||||||
/** **UNSTABLE**: new API, yet to be vetted
|
/** **UNSTABLE**: new API, yet to be vetted
|
||||||
*
|
*
|
||||||
|
@ -933,7 +930,7 @@ declare namespace Deno {
|
||||||
* Requires `allow-net` permission. */
|
* Requires `allow-net` permission. */
|
||||||
export function listenDatagram(
|
export function listenDatagram(
|
||||||
options: ListenOptions & { transport: "udp" },
|
options: ListenOptions & { transport: "udp" },
|
||||||
): DatagramConn<NetAddr>;
|
): DatagramConn;
|
||||||
|
|
||||||
/** **UNSTABLE**: new API, yet to be vetted
|
/** **UNSTABLE**: new API, yet to be vetted
|
||||||
*
|
*
|
||||||
|
@ -949,7 +946,7 @@ declare namespace Deno {
|
||||||
* Requires `allow-read` and `allow-write` permission. */
|
* Requires `allow-read` and `allow-write` permission. */
|
||||||
export function listenDatagram(
|
export function listenDatagram(
|
||||||
options: UnixListenOptions & { transport: "unixpacket" },
|
options: UnixListenOptions & { transport: "unixpacket" },
|
||||||
): DatagramConn<UnixAddr>;
|
): DatagramConn;
|
||||||
|
|
||||||
export interface UnixConnectOptions {
|
export interface UnixConnectOptions {
|
||||||
transport: "unix";
|
transport: "unix";
|
||||||
|
@ -972,11 +969,8 @@ declare namespace Deno {
|
||||||
*
|
*
|
||||||
* Requires `allow-net` permission for "tcp" and `allow-read` for "unix". */
|
* Requires `allow-net` permission for "tcp" and `allow-read` for "unix". */
|
||||||
export function connect(
|
export function connect(
|
||||||
options: ConnectOptions,
|
options: ConnectOptions | UnixConnectOptions,
|
||||||
): Promise<Conn<NetAddr>>;
|
): Promise<Conn>;
|
||||||
export function connect(
|
|
||||||
options: UnixConnectOptions,
|
|
||||||
): Promise<Conn<UnixAddr>>;
|
|
||||||
|
|
||||||
export interface StartTlsOptions {
|
export interface StartTlsOptions {
|
||||||
/** A literal IP address or host name that can be resolved to an IP address.
|
/** A literal IP address or host name that can be resolved to an IP address.
|
||||||
|
@ -1005,7 +999,7 @@ declare namespace Deno {
|
||||||
export function startTls(
|
export function startTls(
|
||||||
conn: Conn,
|
conn: Conn,
|
||||||
options?: StartTlsOptions,
|
options?: StartTlsOptions,
|
||||||
): Promise<Conn<NetAddr>>;
|
): Promise<Conn>;
|
||||||
|
|
||||||
export interface ListenTlsOptions {
|
export interface ListenTlsOptions {
|
||||||
/** **UNSTABLE**: new API, yet to be vetted.
|
/** **UNSTABLE**: new API, yet to be vetted.
|
||||||
|
|
|
@ -18,12 +18,6 @@ unitTest({ perms: { net: true } }, function netTcpListenClose(): void {
|
||||||
listener.close();
|
listener.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { net: true } }, function netListenPortType(): void {
|
|
||||||
const listener = Deno.listen({ port: 0, transport: "tcp" });
|
|
||||||
listener.addr.port;
|
|
||||||
listener.close();
|
|
||||||
});
|
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{
|
{
|
||||||
perms: { net: true },
|
perms: { net: true },
|
||||||
|
|
|
@ -68,12 +68,6 @@
|
||||||
conn,
|
conn,
|
||||||
{ hostname = "127.0.0.1", certFile } = {},
|
{ hostname = "127.0.0.1", certFile } = {},
|
||||||
) {
|
) {
|
||||||
if (
|
|
||||||
!(conn.localAddr.transport === "tcp" ||
|
|
||||||
conn.localAddr.transport === "udp")
|
|
||||||
) {
|
|
||||||
throw new TypeError(`conn is not a valid network connection`);
|
|
||||||
}
|
|
||||||
const res = await opStartTls({
|
const res = await opStartTls({
|
||||||
rid: conn.rid,
|
rid: conn.rid,
|
||||||
hostname,
|
hostname,
|
||||||
|
|
Loading…
Reference in a new issue