mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00:00
feat: Stabilize Deno.connect for 'unix' transport (#21937)
This commit is contained in:
parent
658b559657
commit
fc17ddbcc4
3 changed files with 25 additions and 49 deletions
48
cli/tsc/dts/lib.deno.unstable.d.ts
vendored
48
cli/tsc/dts/lib.deno.unstable.d.ts
vendored
|
@ -1125,54 +1125,6 @@ declare namespace Deno {
|
||||||
options: UnixListenOptions & { transport: "unixpacket" },
|
options: UnixListenOptions & { transport: "unixpacket" },
|
||||||
): DatagramConn;
|
): DatagramConn;
|
||||||
|
|
||||||
/** **UNSTABLE**: New API, yet to be vetted.
|
|
||||||
*
|
|
||||||
* @category Network
|
|
||||||
*/
|
|
||||||
export interface UnixConnectOptions {
|
|
||||||
transport: "unix";
|
|
||||||
path: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** **UNSTABLE**: New API, yet to be vetted.
|
|
||||||
*
|
|
||||||
* Connects to the hostname (default is "127.0.0.1") and port on the named
|
|
||||||
* transport (default is "tcp"), and resolves to the connection (`Conn`).
|
|
||||||
*
|
|
||||||
* ```ts
|
|
||||||
* const conn1 = await Deno.connect({ port: 80 });
|
|
||||||
* const conn2 = await Deno.connect({ hostname: "192.0.2.1", port: 80 });
|
|
||||||
* const conn3 = await Deno.connect({ hostname: "[2001:db8::1]", port: 80 });
|
|
||||||
* const conn4 = await Deno.connect({ hostname: "golang.org", port: 80, transport: "tcp" });
|
|
||||||
* const conn5 = await Deno.connect({ path: "/foo/bar.sock", transport: "unix" });
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Requires `allow-net` permission for "tcp" and `allow-read` for "unix".
|
|
||||||
*
|
|
||||||
* @tags allow-net, allow-read
|
|
||||||
* @category Network
|
|
||||||
*/
|
|
||||||
export function connect(options: ConnectOptions): Promise<TcpConn>;
|
|
||||||
/** **UNSTABLE**: New API, yet to be vetted.
|
|
||||||
*
|
|
||||||
* Connects to the hostname (default is "127.0.0.1") and port on the named
|
|
||||||
* transport (default is "tcp"), and resolves to the connection (`Conn`).
|
|
||||||
*
|
|
||||||
* ```ts
|
|
||||||
* const conn1 = await Deno.connect({ port: 80 });
|
|
||||||
* const conn2 = await Deno.connect({ hostname: "192.0.2.1", port: 80 });
|
|
||||||
* const conn3 = await Deno.connect({ hostname: "[2001:db8::1]", port: 80 });
|
|
||||||
* const conn4 = await Deno.connect({ hostname: "golang.org", port: 80, transport: "tcp" });
|
|
||||||
* const conn5 = await Deno.connect({ path: "/foo/bar.sock", transport: "unix" });
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Requires `allow-net` permission for "tcp" and `allow-read` for "unix".
|
|
||||||
*
|
|
||||||
* @tags allow-net, allow-read
|
|
||||||
* @category Network
|
|
||||||
*/
|
|
||||||
export function connect(options: UnixConnectOptions): Promise<UnixConn>;
|
|
||||||
|
|
||||||
/** **UNSTABLE**: New API, yet to be vetted.
|
/** **UNSTABLE**: New API, yet to be vetted.
|
||||||
*
|
*
|
||||||
* Acquire an advisory file-system lock for the provided file.
|
* Acquire an advisory file-system lock for the provided file.
|
||||||
|
|
25
ext/net/lib.deno_net.d.ts
vendored
25
ext/net/lib.deno_net.d.ts
vendored
|
@ -223,10 +223,35 @@ declare namespace Deno {
|
||||||
setKeepAlive(keepAlive?: boolean): void;
|
setKeepAlive(keepAlive?: boolean): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @category Network */
|
||||||
|
export interface UnixConnectOptions {
|
||||||
|
transport: "unix";
|
||||||
|
path: string;
|
||||||
|
}
|
||||||
|
|
||||||
/** @category Network */
|
/** @category Network */
|
||||||
// deno-lint-ignore no-empty-interface
|
// deno-lint-ignore no-empty-interface
|
||||||
export interface UnixConn extends Conn {}
|
export interface UnixConn extends Conn {}
|
||||||
|
|
||||||
|
/** Connects to the hostname (default is "127.0.0.1") and port on the named
|
||||||
|
* transport (default is "tcp"), and resolves to the connection (`Conn`).
|
||||||
|
*
|
||||||
|
* ```ts
|
||||||
|
* const conn1 = await Deno.connect({ port: 80 });
|
||||||
|
* const conn2 = await Deno.connect({ hostname: "192.0.2.1", port: 80 });
|
||||||
|
* const conn3 = await Deno.connect({ hostname: "[2001:db8::1]", port: 80 });
|
||||||
|
* const conn4 = await Deno.connect({ hostname: "golang.org", port: 80, transport: "tcp" });
|
||||||
|
* const conn5 = await Deno.connect({ path: "/foo/bar.sock", transport: "unix" });
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Requires `allow-net` permission for "tcp" and `allow-read` for "unix".
|
||||||
|
*
|
||||||
|
* @tags allow-net, allow-read
|
||||||
|
* @category Network
|
||||||
|
*/
|
||||||
|
// deno-lint-ignore adjacent-overload-signatures
|
||||||
|
export function connect(options: UnixConnectOptions): Promise<UnixConn>;
|
||||||
|
|
||||||
/** @category Network */
|
/** @category Network */
|
||||||
export interface ConnectTlsOptions {
|
export interface ConnectTlsOptions {
|
||||||
/** The port to connect to. */
|
/** The port to connect to. */
|
||||||
|
|
|
@ -114,7 +114,6 @@ where
|
||||||
NP: NetPermissions + 'static,
|
NP: NetPermissions + 'static,
|
||||||
{
|
{
|
||||||
let address_path = Path::new(&path);
|
let address_path = Path::new(&path);
|
||||||
super::check_unstable(&state.borrow(), "Deno.connect");
|
|
||||||
{
|
{
|
||||||
let mut state_ = state.borrow_mut();
|
let mut state_ = state.borrow_mut();
|
||||||
state_
|
state_
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue