summaryrefslogtreecommitdiff
path: root/cli/dts/lib.deno.ns.d.ts
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2021-06-29 01:43:03 +0200
committerGitHub <noreply@github.com>2021-06-29 01:43:03 +0200
commit38a7128cdd6f3308ba3c13cfb0b0d4ef925a44c3 (patch)
tree8f0c86028d9ba0266f1846e7f3611f7049cb43a8 /cli/dts/lib.deno.ns.d.ts
parent30cba2484815f712502ae8937a25afa13aba0818 (diff)
feat: Add "deno_net" extension (#11150)
This commits moves implementation of net related APIs available on "Deno" namespace to "deno_net" extension. Following APIs were moved: - Deno.listen() - Deno.connect() - Deno.listenTls() - Deno.serveHttp() - Deno.shutdown() - Deno.resolveDns() - Deno.listenDatagram() - Deno.startTls() - Deno.Conn - Deno.Listener - Deno.DatagramConn
Diffstat (limited to 'cli/dts/lib.deno.ns.d.ts')
-rw-r--r--cli/dts/lib.deno.ns.d.ts144
1 files changed, 1 insertions, 143 deletions
diff --git a/cli/dts/lib.deno.ns.d.ts b/cli/dts/lib.deno.ns.d.ts
index e83858586..e1c558f37 100644
--- a/cli/dts/lib.deno.ns.d.ts
+++ b/cli/dts/lib.deno.ns.d.ts
@@ -2,6 +2,7 @@
/// <reference no-default-lib="true" />
/// <reference lib="esnext" />
+/// <reference lib="deno.net" />
/** Deno provides extra properties on `import.meta`. These are included here
* to ensure that these are still available when using the Deno namespace in
@@ -1784,149 +1785,6 @@ declare namespace Deno {
* Requires `allow-write` permission. */
export function truncate(name: string, len?: number): Promise<void>;
- export interface NetAddr {
- transport: "tcp" | "udp";
- hostname: string;
- port: number;
- }
-
- export interface UnixAddr {
- transport: "unix" | "unixpacket";
- path: string;
- }
-
- export type Addr = NetAddr | UnixAddr;
-
- /** A generic network listener for stream-oriented protocols. */
- export interface Listener extends AsyncIterable<Conn> {
- /** Waits for and resolves to the next connection to the `Listener`. */
- accept(): Promise<Conn>;
- /** Close closes the listener. Any pending accept promises will be rejected
- * with errors. */
- close(): void;
- /** Return the address of the `Listener`. */
- readonly addr: Addr;
-
- /** Return the rid of the `Listener`. */
- readonly rid: number;
-
- [Symbol.asyncIterator](): AsyncIterableIterator<Conn>;
- }
-
- export interface Conn extends Reader, Writer, Closer {
- /** The local address of the connection. */
- readonly localAddr: Addr;
- /** The remote address of the connection. */
- readonly remoteAddr: Addr;
- /** The resource ID of the connection. */
- readonly rid: number;
- /** Shuts down (`shutdown(2)`) the write side of the connection. Most
- * callers should just use `close()`. */
- closeWrite(): Promise<void>;
- }
-
- export interface ListenOptions {
- /** The port to listen on. */
- port: number;
- /** A literal IP address or host name that can be resolved to an IP address.
- * If not specified, defaults to `0.0.0.0`. */
- hostname?: string;
- }
-
- /** Listen announces on the local transport address.
- *
- * ```ts
- * const listener1 = Deno.listen({ port: 80 })
- * const listener2 = Deno.listen({ hostname: "192.0.2.1", port: 80 })
- * const listener3 = Deno.listen({ hostname: "[2001:db8::1]", port: 80 });
- * const listener4 = Deno.listen({ hostname: "golang.org", port: 80, transport: "tcp" });
- * ```
- *
- * Requires `allow-net` permission. */
- export function listen(
- options: ListenOptions & { transport?: "tcp" },
- ): Listener;
-
- export interface ListenTlsOptions extends ListenOptions {
- /** Server certificate file. */
- certFile: string;
- /** Server public key file. */
- keyFile: string;
-
- transport?: "tcp";
- }
-
- /** Listen announces on the local transport address over TLS (transport layer
- * security).
- *
- * ```ts
- * const lstnr = Deno.listenTls({ port: 443, certFile: "./server.crt", keyFile: "./server.key" });
- * ```
- *
- * Requires `allow-net` permission. */
- export function listenTls(options: ListenTlsOptions): Listener;
-
- export interface ConnectOptions {
- /** The port to connect to. */
- port: number;
- /** A literal IP address or host name that can be resolved to an IP address.
- * If not specified, defaults to `127.0.0.1`. */
- hostname?: string;
- transport?: "tcp";
- }
-
- /**
- * 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" });
- * ```
- *
- * Requires `allow-net` permission for "tcp". */
- export function connect(options: ConnectOptions): Promise<Conn>;
-
- export interface ConnectTlsOptions {
- /** The port to connect to. */
- port: number;
- /** A literal IP address or host name that can be resolved to an IP address.
- * If not specified, defaults to `127.0.0.1`. */
- hostname?: string;
- /** Server certificate file. */
- certFile?: string;
- }
-
- /** Establishes a secure connection over TLS (transport layer security) using
- * an optional cert file, hostname (default is "127.0.0.1") and port. The
- * cert file is optional and if not included Mozilla's root certificates will
- * be used (see also https://github.com/ctz/webpki-roots for specifics)
- *
- * ```ts
- * const conn1 = await Deno.connectTls({ port: 80 });
- * const conn2 = await Deno.connectTls({ certFile: "./certs/my_custom_root_CA.pem", hostname: "192.0.2.1", port: 80 });
- * const conn3 = await Deno.connectTls({ hostname: "[2001:db8::1]", port: 80 });
- * const conn4 = await Deno.connectTls({ certFile: "./certs/my_custom_root_CA.pem", hostname: "golang.org", port: 80});
- * ```
- *
- * Requires `allow-net` permission.
- */
- export function connectTls(options: ConnectTlsOptions): Promise<Conn>;
-
- /** Shutdown socket send operations.
- *
- * Matches behavior of POSIX shutdown(3).
- *
- * ```ts
- * const listener = Deno.listen({ port: 80 });
- * const conn = await listener.accept();
- * Deno.shutdown(conn.rid);
- * ```
- */
- export function shutdown(rid: number): Promise<void>;
-
export interface Metrics {
opsDispatched: number;
opsDispatchedSync: number;