mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 20:29:11 +00:00
fix: vsock nits (#28851)
This commit is contained in:
parent
5b25eeda57
commit
e73ed03373
6 changed files with 54 additions and 21 deletions
23
cli/tsc/dts/lib.deno.ns.d.ts
vendored
23
cli/tsc/dts/lib.deno.ns.d.ts
vendored
|
@ -5162,7 +5162,9 @@ declare namespace Deno {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Options that can be passed to `Deno.serve` to create a server listening on
|
* Options that can be passed to `Deno.serve` to create a server listening on
|
||||||
* a vsock socket.
|
* a VSOCK socket.
|
||||||
|
*
|
||||||
|
* @experimental **UNSTABLE**: New API, yet to be vetted.
|
||||||
*
|
*
|
||||||
* @category HTTP Server
|
* @category HTTP Server
|
||||||
*/
|
*/
|
||||||
|
@ -5280,7 +5282,11 @@ declare namespace Deno {
|
||||||
): HttpServer<Deno.UnixAddr>;
|
): HttpServer<Deno.UnixAddr>;
|
||||||
/** Serves HTTP requests with the given option bag and handler.
|
/** Serves HTTP requests with the given option bag and handler.
|
||||||
*
|
*
|
||||||
* You can specify the socket path with `path` option.
|
* @experimental **UNSTABLE**: New API, yet to be vetted.
|
||||||
|
*
|
||||||
|
* You can specify an object with the cid and port options for the VSOCK interface.
|
||||||
|
*
|
||||||
|
* The VSOCK address family facilitates communication between virtual machines and the host they are running on: https://man7.org/linux/man-pages/man7/vsock.7.html
|
||||||
*
|
*
|
||||||
* ```ts
|
* ```ts
|
||||||
* Deno.serve(
|
* Deno.serve(
|
||||||
|
@ -5307,9 +5313,9 @@ declare namespace Deno {
|
||||||
* ac.abort();
|
* ac.abort();
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* By default `Deno.serve` prints the message
|
* By default `Deno.serve` prints the message `Listening on cid:port`.
|
||||||
* `Listening on path/to/socket` on listening. If you like to
|
* If you want to change this behavior, you can specify a custom `onListen`
|
||||||
* change this behavior, you can specify a custom `onListen` callback.
|
* callback.
|
||||||
*
|
*
|
||||||
* ```ts
|
* ```ts
|
||||||
* Deno.serve({
|
* Deno.serve({
|
||||||
|
@ -5417,8 +5423,11 @@ declare namespace Deno {
|
||||||
): HttpServer<Deno.UnixAddr>;
|
): HttpServer<Deno.UnixAddr>;
|
||||||
/** Serves HTTP requests with the given option bag.
|
/** Serves HTTP requests with the given option bag.
|
||||||
*
|
*
|
||||||
* You can specify an object with the path option, which is the
|
* The VSOCK address family facilitates communication between virtual machines and the host they are running on: https://man7.org/linux/man-pages/man7/vsock.7.html
|
||||||
* vsock socket to listen on.
|
*
|
||||||
|
* @experimental **UNSTABLE**: New API, yet to be vetted.
|
||||||
|
*
|
||||||
|
* You can specify an object with the cid and port options for the VSOCK interface.
|
||||||
*
|
*
|
||||||
* ```ts
|
* ```ts
|
||||||
* const ac = new AbortController();
|
* const ac = new AbortController();
|
||||||
|
|
24
cli/tsc/dts/lib.deno_net.d.ts
vendored
24
cli/tsc/dts/lib.deno_net.d.ts
vendored
|
@ -18,7 +18,10 @@ declare namespace Deno {
|
||||||
path: string;
|
path: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @category Network */
|
/**
|
||||||
|
* @experimental **UNSTABLE**: New API, yet to be vetted.
|
||||||
|
* @category Network
|
||||||
|
*/
|
||||||
export interface VsockAddr {
|
export interface VsockAddr {
|
||||||
transport: "vsock";
|
transport: "vsock";
|
||||||
cid: number;
|
cid: number;
|
||||||
|
@ -74,7 +77,9 @@ declare namespace Deno {
|
||||||
*/
|
*/
|
||||||
export type UnixListener = Listener<UnixConn, UnixAddr>;
|
export type UnixListener = Listener<UnixConn, UnixAddr>;
|
||||||
|
|
||||||
/** Specialized listener that accepts Vsock connections.
|
/** Specialized listener that accepts VSOCK connections.
|
||||||
|
*
|
||||||
|
* @experimental **UNSTABLE**: New API, yet to be vetted.
|
||||||
*
|
*
|
||||||
* @category Network
|
* @category Network
|
||||||
*/
|
*/
|
||||||
|
@ -236,9 +241,11 @@ declare namespace Deno {
|
||||||
options: UnixListenOptions & { transport: "unix" },
|
options: UnixListenOptions & { transport: "unix" },
|
||||||
): UnixListener;
|
): UnixListener;
|
||||||
|
|
||||||
/** Options which can be set when opening a vsock listener via
|
/** Options which can be set when opening a VSOCK listener via
|
||||||
* {@linkcode Deno.listen}.
|
* {@linkcode Deno.listen}.
|
||||||
*
|
*
|
||||||
|
* @experimental **UNSTABLE**: New API, yet to be vetted.
|
||||||
|
*
|
||||||
* @category Network
|
* @category Network
|
||||||
*/
|
*/
|
||||||
export interface VsockListenOptions {
|
export interface VsockListenOptions {
|
||||||
|
@ -247,6 +254,10 @@ declare namespace Deno {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Listen announces on the local transport address.
|
/** Listen announces on the local transport address.
|
||||||
|
*
|
||||||
|
* @experimental **UNSTABLE**: New API, yet to be vetted.
|
||||||
|
*
|
||||||
|
* The VSOCK address family facilitates communication between virtual machines and the host they are running on: https://man7.org/linux/man-pages/man7/vsock.7.html
|
||||||
*
|
*
|
||||||
* ```ts
|
* ```ts
|
||||||
* const listener = Deno.listen({ cid: -1, port: 80, transport: "vsock" })
|
* const listener = Deno.listen({ cid: -1, port: 80, transport: "vsock" })
|
||||||
|
@ -389,7 +400,10 @@ declare namespace Deno {
|
||||||
// deno-lint-ignore adjacent-overload-signatures
|
// deno-lint-ignore adjacent-overload-signatures
|
||||||
export function connect(options: UnixConnectOptions): Promise<UnixConn>;
|
export function connect(options: UnixConnectOptions): Promise<UnixConn>;
|
||||||
|
|
||||||
/** @category Network */
|
/**
|
||||||
|
* @experimental **UNSTABLE**: New API, yet to be vetted.
|
||||||
|
* @category Network
|
||||||
|
*/
|
||||||
export interface VsockConnectOptions {
|
export interface VsockConnectOptions {
|
||||||
transport: "vsock";
|
transport: "vsock";
|
||||||
cid: number;
|
cid: number;
|
||||||
|
@ -402,6 +416,8 @@ declare namespace Deno {
|
||||||
/** Connects to the hostname (default is "127.0.0.1") and port on the named
|
/** 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`).
|
* transport (default is "tcp"), and resolves to the connection (`Conn`).
|
||||||
*
|
*
|
||||||
|
* @experimental **UNSTABLE**: New API, yet to be vetted.
|
||||||
|
*
|
||||||
* ```ts
|
* ```ts
|
||||||
* const conn1 = await Deno.connect({ port: 80 });
|
* const conn1 = await Deno.connect({ port: 80 });
|
||||||
* const conn2 = await Deno.connect({ hostname: "192.0.2.1", port: 80 });
|
* const conn2 = await Deno.connect({ hostname: "192.0.2.1", port: 80 });
|
||||||
|
|
|
@ -625,10 +625,10 @@ where
|
||||||
use tokio_vsock::VsockAddr;
|
use tokio_vsock::VsockAddr;
|
||||||
use tokio_vsock::VsockStream;
|
use tokio_vsock::VsockStream;
|
||||||
|
|
||||||
super::check_unstable(
|
state
|
||||||
&state.borrow(),
|
.borrow()
|
||||||
r#"Deno.connect({ transport: "vsock" })"#,
|
.feature_checker
|
||||||
);
|
.check_or_exit("vsock", "Deno.connect");
|
||||||
|
|
||||||
state.borrow_mut().borrow_mut::<NP>().check_vsock(
|
state.borrow_mut().borrow_mut::<NP>().check_vsock(
|
||||||
cid,
|
cid,
|
||||||
|
@ -680,7 +680,7 @@ where
|
||||||
use tokio_vsock::VsockAddr;
|
use tokio_vsock::VsockAddr;
|
||||||
use tokio_vsock::VsockListener;
|
use tokio_vsock::VsockListener;
|
||||||
|
|
||||||
super::check_unstable(state, r#"Deno.listen({ transport: "vsock" })"#);
|
state.feature_checker.check_or_exit("vsock", "Deno.listen");
|
||||||
|
|
||||||
state
|
state
|
||||||
.borrow_mut::<NP>()
|
.borrow_mut::<NP>()
|
||||||
|
|
|
@ -164,8 +164,9 @@ const unstableIds = {
|
||||||
process: 11,
|
process: 11,
|
||||||
temporal: 12,
|
temporal: 12,
|
||||||
unsafeProto: 13,
|
unsafeProto: 13,
|
||||||
webgpu: 14,
|
vsock: 14,
|
||||||
workerOptions: 15,
|
webgpu: 15,
|
||||||
|
workerOptions: 16,
|
||||||
};
|
};
|
||||||
|
|
||||||
const denoNsUnstableById = { __proto__: null };
|
const denoNsUnstableById = { __proto__: null };
|
||||||
|
|
|
@ -62,7 +62,7 @@ pub struct UnstableGranularFlag {
|
||||||
pub id: i32,
|
pub id: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE(bartlomieju): keep IDs in sync with `runtime/90_deno_ns.js` (search for `unstableFeatures`)
|
// NOTE(bartlomieju): keep IDs in sync with `runtime/js/90_deno_ns.js` (search for `unstableFeatures`)
|
||||||
pub static UNSTABLE_GRANULAR_FLAGS: &[UnstableGranularFlag] = &[
|
pub static UNSTABLE_GRANULAR_FLAGS: &[UnstableGranularFlag] = &[
|
||||||
UnstableGranularFlag {
|
UnstableGranularFlag {
|
||||||
name: deno_broadcast_channel::UNSTABLE_FEATURE_NAME,
|
name: deno_broadcast_channel::UNSTABLE_FEATURE_NAME,
|
||||||
|
@ -145,17 +145,23 @@ pub static UNSTABLE_GRANULAR_FLAGS: &[UnstableGranularFlag] = &[
|
||||||
// for "unstableIds" to see where it's used.
|
// for "unstableIds" to see where it's used.
|
||||||
id: 13,
|
id: 13,
|
||||||
},
|
},
|
||||||
|
UnstableGranularFlag {
|
||||||
|
name: "vsock",
|
||||||
|
help_text: "Enable unstable VSOCK APIs",
|
||||||
|
show_in_help: false,
|
||||||
|
id: 14,
|
||||||
|
},
|
||||||
UnstableGranularFlag {
|
UnstableGranularFlag {
|
||||||
name: deno_webgpu::UNSTABLE_FEATURE_NAME,
|
name: deno_webgpu::UNSTABLE_FEATURE_NAME,
|
||||||
help_text: "Enable unstable `WebGPU` APIs",
|
help_text: "Enable unstable `WebGPU` APIs",
|
||||||
show_in_help: true,
|
show_in_help: true,
|
||||||
id: 14,
|
id: 15,
|
||||||
},
|
},
|
||||||
UnstableGranularFlag {
|
UnstableGranularFlag {
|
||||||
name: ops::worker_host::UNSTABLE_FEATURE_NAME,
|
name: ops::worker_host::UNSTABLE_FEATURE_NAME,
|
||||||
help_text: "Enable unstable Web Worker APIs",
|
help_text: "Enable unstable Web Worker APIs",
|
||||||
show_in_help: true,
|
show_in_help: true,
|
||||||
id: 15,
|
id: 16,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -128,6 +128,7 @@ fn js_unit_test(test: String) {
|
||||||
// flag to particular files, but there's many of them that rely on unstable
|
// flag to particular files, but there's many of them that rely on unstable
|
||||||
// net APIs (`reusePort` in `listen` and `listenTls`; `listenDatagram`)
|
// net APIs (`reusePort` in `listen` and `listenTls`; `listenDatagram`)
|
||||||
.arg("--unstable-net")
|
.arg("--unstable-net")
|
||||||
|
.arg("--unstable-vsock")
|
||||||
.arg("--location=http://127.0.0.1:4545/")
|
.arg("--location=http://127.0.0.1:4545/")
|
||||||
.arg("--no-prompt");
|
.arg("--no-prompt");
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue