mirror of
https://github.com/denoland/deno.git
synced 2025-08-04 02:48:24 +00:00
feat: support linux vsock (#28725)
impl support for vsock https://man7.org/linux/man-pages/man7/vsock.7.html
This commit is contained in:
parent
7218113d24
commit
9da231dc7a
17 changed files with 680 additions and 28 deletions
71
cli/tsc/dts/lib.deno_net.d.ts
vendored
71
cli/tsc/dts/lib.deno_net.d.ts
vendored
|
@ -19,7 +19,14 @@ declare namespace Deno {
|
|||
}
|
||||
|
||||
/** @category Network */
|
||||
export type Addr = NetAddr | UnixAddr;
|
||||
export interface VsockAddr {
|
||||
transport: "vsock";
|
||||
cid: number;
|
||||
port: number;
|
||||
}
|
||||
|
||||
/** @category Network */
|
||||
export type Addr = NetAddr | UnixAddr | VsockAddr;
|
||||
|
||||
/** A generic network listener for stream-oriented protocols.
|
||||
*
|
||||
|
@ -67,6 +74,12 @@ declare namespace Deno {
|
|||
*/
|
||||
export type UnixListener = Listener<UnixConn, UnixAddr>;
|
||||
|
||||
/** Specialized listener that accepts Vsock connections.
|
||||
*
|
||||
* @category Network
|
||||
*/
|
||||
export type VsockListener = Listener<VsockConn, VsockAddr>;
|
||||
|
||||
/** @category Network */
|
||||
export interface Conn<A extends Addr = Addr> extends Disposable {
|
||||
/** Read the incoming data from the connection into an array buffer (`p`).
|
||||
|
@ -223,6 +236,32 @@ declare namespace Deno {
|
|||
options: UnixListenOptions & { transport: "unix" },
|
||||
): UnixListener;
|
||||
|
||||
/** Options which can be set when opening a vsock listener via
|
||||
* {@linkcode Deno.listen}.
|
||||
*
|
||||
* @category Network
|
||||
*/
|
||||
export interface VsockListenOptions {
|
||||
cid: number;
|
||||
port: number;
|
||||
}
|
||||
|
||||
/** Listen announces on the local transport address.
|
||||
*
|
||||
* ```ts
|
||||
* const listener = Deno.listen({ cid: -1, port: 80, transport: "vsock" })
|
||||
* ```
|
||||
*
|
||||
* Requires `allow-net` permission.
|
||||
*
|
||||
* @tags allow-net
|
||||
* @category Network
|
||||
*/
|
||||
// deno-lint-ignore adjacent-overload-signatures
|
||||
export function listen(
|
||||
options: VsockListenOptions & { transport: "vsock" },
|
||||
): VsockListener;
|
||||
|
||||
/**
|
||||
* Provides certified key material from strings. The key material is provided in
|
||||
* `PEM`-format (Privacy Enhanced Mail, https://www.rfc-editor.org/rfc/rfc1422) which can be identified by having
|
||||
|
@ -350,6 +389,36 @@ declare namespace Deno {
|
|||
// deno-lint-ignore adjacent-overload-signatures
|
||||
export function connect(options: UnixConnectOptions): Promise<UnixConn>;
|
||||
|
||||
/** @category Network */
|
||||
export interface VsockConnectOptions {
|
||||
transport: "vsock";
|
||||
cid: number;
|
||||
port: number;
|
||||
}
|
||||
|
||||
/** @category Network */
|
||||
export interface VsockConn extends Conn<VsockAddr> {}
|
||||
|
||||
/** 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" });
|
||||
* const conn6 = await Deno.connect({ cid: -1, port: 80, transport: "vsock" });
|
||||
* ```
|
||||
*
|
||||
* Requires `allow-net` permission for "tcp" and "vsock", and `allow-read` for "unix".
|
||||
*
|
||||
* @tags allow-net, allow-read
|
||||
* @category Network
|
||||
*/
|
||||
// deno-lint-ignore adjacent-overload-signatures
|
||||
export function connect(options: VsockConnectOptions): Promise<VsockConn>;
|
||||
|
||||
/** @category Network */
|
||||
export interface ConnectTlsOptions {
|
||||
/** The port to connect to. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue