UNPKG

@dynatrace/js-runtime

Version:

This package provides the Dynatrace JavaScript runtime used by the [Dynatrace App Toolkit](https://www.npmjs.com/package/dt-app).

901 lines 58.2 kB
/** * This module is not supported by the Dynatrace JavaScript Runtime and only * exists for its referenced types. * See the `Node.js Compatibility` section for more information. * @see https://dt-url.net/runtime-apis */ // DT-disabled // /** // DT-disabled // * > Stability: 2 - Stable // DT-disabled // * // DT-disabled // * The `node:net` module provides an asynchronous network API for creating stream-based // DT-disabled // * TCP or `IPC` servers ({@link createServer}) and clients // DT-disabled // * ({@link createConnection}). // DT-disabled // * // DT-disabled // * It can be accessed using: // DT-disabled // * // DT-disabled // * ```js // DT-disabled // * import net from 'node:net'; // DT-disabled // * ``` // DT-disabled // * @see [source](https://github.com/nodejs/node/blob/v22.x/lib/net.js) // DT-disabled // */ declare module "net" { import * as stream from "node:stream"; // DT-disabled // import { Abortable, EventEmitter } from "node:events"; import * as dns from "node:dns"; type LookupFunction = ( hostname: string, options: dns.LookupOptions, callback: (err: NodeJS.ErrnoException | null, address: string | dns.LookupAddress[], family?: number) => void, ) => void; interface AddressInfo { address: string; family: string; port: number; } interface SocketConstructorOpts { fd?: number | undefined; allowHalfOpen?: boolean | undefined; onread?: OnReadOpts | undefined; readable?: boolean | undefined; writable?: boolean | undefined; signal?: AbortSignal; } interface OnReadOpts { buffer: Uint8Array | (() => Uint8Array); /** * This function is called for every chunk of incoming data. * Two arguments are passed to it: the number of bytes written to `buffer` and a reference to `buffer`. * Return `false` from this function to implicitly `pause()` the socket. */ callback(bytesWritten: number, buffer: Uint8Array): boolean; } // TODO: remove empty ConnectOpts placeholder at next major @types/node version. /** @deprecated */ interface ConnectOpts {} interface TcpSocketConnectOpts { port: number; host?: string | undefined; localAddress?: string | undefined; localPort?: number | undefined; hints?: number | undefined; family?: number | undefined; lookup?: LookupFunction | undefined; noDelay?: boolean | undefined; keepAlive?: boolean | undefined; keepAliveInitialDelay?: number | undefined; /** * @since v18.13.0 */ autoSelectFamily?: boolean | undefined; /** * @since v18.13.0 */ autoSelectFamilyAttemptTimeout?: number | undefined; // DT-disabled // blockList?: BlockList | undefined; } interface IpcSocketConnectOpts { path: string; } type SocketConnectOpts = TcpSocketConnectOpts | IpcSocketConnectOpts; type SocketReadyState = "opening" | "open" | "readOnly" | "writeOnly" | "closed"; /** * This class is an abstraction of a TCP socket or a streaming `IPC` endpoint * (uses named pipes on Windows, and Unix domain sockets otherwise). It is also * an `EventEmitter`. * * A `net.Socket` can be created by the user and used directly to interact with * a server. For example, it is returned by {@link createConnection}, * so the user can use it to talk to the server. * * It can also be created by Node.js and passed to the user when a connection * is received. For example, it is passed to the listeners of a `'connection'` event emitted on a {@link Server}, so the user can use * it to interact with the client. * @since v0.3.4 */ class Socket extends stream.Duplex { constructor(options?: SocketConstructorOpts); /** * Destroys the socket after all data is written. If the `finish` event was already emitted the socket is destroyed immediately. * If the socket is still writable it implicitly calls `socket.end()`. * @since v0.3.4 */ destroySoon(): void; /** * Sends data on the socket. The second parameter specifies the encoding in the * case of a string. It defaults to UTF8 encoding. * * Returns `true` if the entire data was flushed successfully to the kernel * buffer. Returns `false` if all or part of the data was queued in user memory.`'drain'` will be emitted when the buffer is again free. * * The optional `callback` parameter will be executed when the data is finally * written out, which may not be immediately. * * See `Writable` stream `write()` method for more * information. * @since v0.1.90 * @param [encoding='utf8'] Only used when data is `string`. */ write(buffer: Uint8Array | string, cb?: (err?: Error) => void): boolean; write(str: Uint8Array | string, encoding?: BufferEncoding, cb?: (err?: Error) => void): boolean; /** * Initiate a connection on a given socket. * * Possible signatures: * * * `socket.connect(options[, connectListener])` * * `socket.connect(path[, connectListener])` for `IPC` connections. * * `socket.connect(port[, host][, connectListener])` for TCP connections. * * Returns: `net.Socket` The socket itself. * * This function is asynchronous. When the connection is established, the `'connect'` event will be emitted. If there is a problem connecting, * instead of a `'connect'` event, an `'error'` event will be emitted with * the error passed to the `'error'` listener. * The last parameter `connectListener`, if supplied, will be added as a listener * for the `'connect'` event **once**. * * This function should only be used for reconnecting a socket after`'close'` has been emitted or otherwise it may lead to undefined * behavior. */ connect(options: SocketConnectOpts, connectionListener?: () => void): this; connect(port: number, host: string, connectionListener?: () => void): this; connect(port: number, connectionListener?: () => void): this; connect(path: string, connectionListener?: () => void): this; /** * Set the encoding for the socket as a `Readable Stream`. See `readable.setEncoding()` for more information. * @since v0.1.90 * @return The socket itself. */ setEncoding(encoding?: BufferEncoding): this; /** * Pauses the reading of data. That is, `'data'` events will not be emitted. * Useful to throttle back an upload. * @return The socket itself. */ pause(): this; /** * Close the TCP connection by sending an RST packet and destroy the stream. * If this TCP socket is in connecting status, it will send an RST packet and destroy this TCP socket once it is connected. * Otherwise, it will call `socket.destroy` with an `ERR_SOCKET_CLOSED` Error. * If this is not a TCP socket (for example, a pipe), calling this method will immediately throw an `ERR_INVALID_HANDLE_TYPE` Error. * @since v18.3.0, v16.17.0 */ resetAndDestroy(): this; /** * Resumes reading after a call to `socket.pause()`. * @return The socket itself. */ resume(): this; /** * Sets the socket to timeout after `timeout` milliseconds of inactivity on * the socket. By default `net.Socket` do not have a timeout. * * When an idle timeout is triggered the socket will receive a `'timeout'` event but the connection will not be severed. The user must manually call `socket.end()` or `socket.destroy()` to * end the connection. * * ```js * socket.setTimeout(3000); * socket.on('timeout', () => { * console.log('socket timeout'); * socket.end(); * }); * ``` * * If `timeout` is 0, then the existing idle timeout is disabled. * * The optional `callback` parameter will be added as a one-time listener for the `'timeout'` event. * @since v0.1.90 * @return The socket itself. */ setTimeout(timeout: number, callback?: () => void): this; /** * Enable/disable the use of Nagle's algorithm. * * When a TCP connection is created, it will have Nagle's algorithm enabled. * * Nagle's algorithm delays data before it is sent via the network. It attempts * to optimize throughput at the expense of latency. * * Passing `true` for `noDelay` or not passing an argument will disable Nagle's * algorithm for the socket. Passing `false` for `noDelay` will enable Nagle's * algorithm. * @since v0.1.90 * @param [noDelay=true] * @return The socket itself. */ setNoDelay(noDelay?: boolean): this; /** * Enable/disable keep-alive functionality, and optionally set the initial * delay before the first keepalive probe is sent on an idle socket. * * Set `initialDelay` (in milliseconds) to set the delay between the last * data packet received and the first keepalive probe. Setting `0` for`initialDelay` will leave the value unchanged from the default * (or previous) setting. * * Enabling the keep-alive functionality will set the following socket options: * * * `SO_KEEPALIVE=1` * * `TCP_KEEPIDLE=initialDelay` * * `TCP_KEEPCNT=10` * * `TCP_KEEPINTVL=1` * @since v0.1.92 * @param [enable=false] * @param [initialDelay=0] * @return The socket itself. */ setKeepAlive(enable?: boolean, initialDelay?: number): this; /** * Returns the bound `address`, the address `family` name and `port` of the * socket as reported by the operating system:`{ port: 12346, family: 'IPv4', address: '127.0.0.1' }` * @since v0.1.90 */ address(): AddressInfo | {}; /** * Calling `unref()` on a socket will allow the program to exit if this is the only * active socket in the event system. If the socket is already `unref`ed calling`unref()` again will have no effect. * @since v0.9.1 * @return The socket itself. */ unref(): this; /** * Opposite of `unref()`, calling `ref()` on a previously `unref`ed socket will _not_ let the program exit if it's the only socket left (the default behavior). * If the socket is `ref`ed calling `ref` again will have no effect. * @since v0.9.1 * @return The socket itself. */ ref(): this; /** * This property is only present if the family autoselection algorithm is enabled in `socket.connect(options)` * and it is an array of the addresses that have been attempted. * * Each address is a string in the form of `$IP:$PORT`. * If the connection was successful, then the last address is the one that the socket is currently connected to. * @since v19.4.0 */ readonly autoSelectFamilyAttemptedAddresses: string[]; /** * This property shows the number of characters buffered for writing. The buffer * may contain strings whose length after encoding is not yet known. So this number * is only an approximation of the number of bytes in the buffer. * * `net.Socket` has the property that `socket.write()` always works. This is to * help users get up and running quickly. The computer cannot always keep up * with the amount of data that is written to a socket. The network connection * simply might be too slow. Node.js will internally queue up the data written to a * socket and send it out over the wire when it is possible. * * The consequence of this internal buffering is that memory may grow. * Users who experience large or growing `bufferSize` should attempt to * "throttle" the data flows in their program with `socket.pause()` and `socket.resume()`. * @since v0.3.8 * @deprecated Since v14.6.0 - Use `writableLength` instead. */ readonly bufferSize: number; /** * The amount of received bytes. * @since v0.5.3 */ readonly bytesRead: number; /** * The amount of bytes sent. * @since v0.5.3 */ readonly bytesWritten: number; /** * If `true`, `socket.connect(options[, connectListener])` was * called and has not yet finished. It will stay `true` until the socket becomes * connected, then it is set to `false` and the `'connect'` event is emitted. Note * that the `socket.connect(options[, connectListener])` callback is a listener for the `'connect'` event. * @since v6.1.0 */ readonly connecting: boolean; /** * This is `true` if the socket is not connected yet, either because `.connect()`has not yet been called or because it is still in the process of connecting * (see `socket.connecting`). * @since v11.2.0, v10.16.0 */ readonly pending: boolean; /** * See `writable.destroyed` for further details. */ readonly destroyed: boolean; /** * The string representation of the local IP address the remote client is * connecting on. For example, in a server listening on `'0.0.0.0'`, if a client * connects on `'192.168.1.1'`, the value of `socket.localAddress` would be`'192.168.1.1'`. * @since v0.9.6 */ readonly localAddress?: string; /** * The numeric representation of the local port. For example, `80` or `21`. * @since v0.9.6 */ readonly localPort?: number; /** * The string representation of the local IP family. `'IPv4'` or `'IPv6'`. * @since v18.8.0, v16.18.0 */ readonly localFamily?: string; /** * This property represents the state of the connection as a string. * * * If the stream is connecting `socket.readyState` is `opening`. * * If the stream is readable and writable, it is `open`. * * If the stream is readable and not writable, it is `readOnly`. * * If the stream is not readable and writable, it is `writeOnly`. * @since v0.5.0 */ readonly readyState: SocketReadyState; /** * The string representation of the remote IP address. For example,`'74.125.127.100'` or `'2001:4860:a005::68'`. Value may be `undefined` if * the socket is destroyed (for example, if the client disconnected). * @since v0.5.10 */ readonly remoteAddress?: string | undefined; /** * The string representation of the remote IP family. `'IPv4'` or `'IPv6'`. Value may be `undefined` if * the socket is destroyed (for example, if the client disconnected). * @since v0.11.14 */ readonly remoteFamily?: string | undefined; /** * The numeric representation of the remote port. For example, `80` or `21`. Value may be `undefined` if * the socket is destroyed (for example, if the client disconnected). * @since v0.5.10 */ readonly remotePort?: number | undefined; /** * The socket timeout in milliseconds as set by `socket.setTimeout()`. * It is `undefined` if a timeout has not been set. * @since v10.7.0 */ readonly timeout?: number | undefined; /** * Half-closes the socket. i.e., it sends a FIN packet. It is possible the * server will still send some data. * * See `writable.end()` for further details. * @since v0.1.90 * @param [encoding='utf8'] Only used when data is `string`. * @param callback Optional callback for when the socket is finished. * @return The socket itself. */ end(callback?: () => void): this; end(buffer: Uint8Array | string, callback?: () => void): this; end(str: Uint8Array | string, encoding?: BufferEncoding, callback?: () => void): this; /** * events.EventEmitter * 1. close * 2. connect * 3. connectionAttempt * 4. connectionAttemptFailed * 5. connectionAttemptTimeout * 6. data * 7. drain * 8. end * 9. error * 10. lookup * 11. ready * 12. timeout */ addListener(event: string, listener: (...args: any[]) => void): this; addListener(event: "close", listener: (hadError: boolean) => void): this; addListener(event: "connect", listener: () => void): this; addListener(event: "connectionAttempt", listener: (ip: string, port: number, family: number) => void): this; addListener( event: "connectionAttemptFailed", listener: (ip: string, port: number, family: number, error: Error) => void, ): this; addListener( event: "connectionAttemptTimeout", listener: (ip: string, port: number, family: number) => void, ): this; addListener(event: "data", listener: (data: Buffer) => void): this; addListener(event: "drain", listener: () => void): this; addListener(event: "end", listener: () => void): this; addListener(event: "error", listener: (err: Error) => void): this; addListener( event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void, ): this; addListener(event: "ready", listener: () => void): this; addListener(event: "timeout", listener: () => void): this; emit(event: string | symbol, ...args: any[]): boolean; emit(event: "close", hadError: boolean): boolean; emit(event: "connect"): boolean; emit(event: "connectionAttempt", ip: string, port: number, family: number): boolean; emit(event: "connectionAttemptFailed", ip: string, port: number, family: number, error: Error): boolean; emit(event: "connectionAttemptTimeout", ip: string, port: number, family: number): boolean; emit(event: "data", data: Buffer): boolean; emit(event: "drain"): boolean; emit(event: "end"): boolean; emit(event: "error", err: Error): boolean; emit(event: "lookup", err: Error, address: string, family: string | number, host: string): boolean; emit(event: "ready"): boolean; emit(event: "timeout"): boolean; on(event: string, listener: (...args: any[]) => void): this; on(event: "close", listener: (hadError: boolean) => void): this; on(event: "connect", listener: () => void): this; on(event: "connectionAttempt", listener: (ip: string, port: number, family: number) => void): this; on( event: "connectionAttemptFailed", listener: (ip: string, port: number, family: number, error: Error) => void, ): this; on(event: "connectionAttemptTimeout", listener: (ip: string, port: number, family: number) => void): this; on(event: "data", listener: (data: Buffer) => void): this; on(event: "drain", listener: () => void): this; on(event: "end", listener: () => void): this; on(event: "error", listener: (err: Error) => void): this; on( event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void, ): this; on(event: "ready", listener: () => void): this; on(event: "timeout", listener: () => void): this; once(event: string, listener: (...args: any[]) => void): this; once(event: "close", listener: (hadError: boolean) => void): this; once(event: "connectionAttempt", listener: (ip: string, port: number, family: number) => void): this; once( event: "connectionAttemptFailed", listener: (ip: string, port: number, family: number, error: Error) => void, ): this; once(event: "connectionAttemptTimeout", listener: (ip: string, port: number, family: number) => void): this; once(event: "connect", listener: () => void): this; once(event: "data", listener: (data: Buffer) => void): this; once(event: "drain", listener: () => void): this; once(event: "end", listener: () => void): this; once(event: "error", listener: (err: Error) => void): this; once( event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void, ): this; once(event: "ready", listener: () => void): this; once(event: "timeout", listener: () => void): this; prependListener(event: string, listener: (...args: any[]) => void): this; prependListener(event: "close", listener: (hadError: boolean) => void): this; prependListener(event: "connect", listener: () => void): this; prependListener(event: "connectionAttempt", listener: (ip: string, port: number, family: number) => void): this; prependListener( event: "connectionAttemptFailed", listener: (ip: string, port: number, family: number, error: Error) => void, ): this; prependListener( event: "connectionAttemptTimeout", listener: (ip: string, port: number, family: number) => void, ): this; prependListener(event: "data", listener: (data: Buffer) => void): this; prependListener(event: "drain", listener: () => void): this; prependListener(event: "end", listener: () => void): this; prependListener(event: "error", listener: (err: Error) => void): this; prependListener( event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void, ): this; prependListener(event: "ready", listener: () => void): this; prependListener(event: "timeout", listener: () => void): this; prependOnceListener(event: string, listener: (...args: any[]) => void): this; prependOnceListener(event: "close", listener: (hadError: boolean) => void): this; prependOnceListener(event: "connect", listener: () => void): this; prependOnceListener( event: "connectionAttempt", listener: (ip: string, port: number, family: number) => void, ): this; prependOnceListener( event: "connectionAttemptFailed", listener: (ip: string, port: number, family: number, error: Error) => void, ): this; prependOnceListener( event: "connectionAttemptTimeout", listener: (ip: string, port: number, family: number) => void, ): this; prependOnceListener(event: "data", listener: (data: Buffer) => void): this; prependOnceListener(event: "drain", listener: () => void): this; prependOnceListener(event: "end", listener: () => void): this; prependOnceListener(event: "error", listener: (err: Error) => void): this; prependOnceListener( event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void, ): this; prependOnceListener(event: "ready", listener: () => void): this; prependOnceListener(event: "timeout", listener: () => void): this; } // DT-disabled // interface ListenOptions extends Abortable { // DT-disabled // backlog?: number | undefined; // DT-disabled // exclusive?: boolean | undefined; // DT-disabled // host?: string | undefined; // DT-disabled // /** // DT-disabled // * @default false // DT-disabled // */ // DT-disabled // ipv6Only?: boolean | undefined; // DT-disabled // reusePort?: boolean | undefined; // DT-disabled // path?: string | undefined; // DT-disabled // port?: number | undefined; // DT-disabled // readableAll?: boolean | undefined; // DT-disabled // writableAll?: boolean | undefined; // DT-disabled // } // DT-disabled // interface ServerOpts { // DT-disabled // /** // DT-disabled // * Indicates whether half-opened TCP connections are allowed. // DT-disabled // * @default false // DT-disabled // */ // DT-disabled // allowHalfOpen?: boolean | undefined; // DT-disabled // /** // DT-disabled // * Indicates whether the socket should be paused on incoming connections. // DT-disabled // * @default false // DT-disabled // */ // DT-disabled // pauseOnConnect?: boolean | undefined; // DT-disabled // /** // DT-disabled // * If set to `true`, it disables the use of Nagle's algorithm immediately after a new incoming connection is received. // DT-disabled // * @default false // DT-disabled // * @since v16.5.0 // DT-disabled // */ // DT-disabled // noDelay?: boolean | undefined; // DT-disabled // /** // DT-disabled // * If set to `true`, it enables keep-alive functionality on the socket immediately after a new incoming connection is received, // DT-disabled // * similarly on what is done in `socket.setKeepAlive([enable][, initialDelay])`. // DT-disabled // * @default false // DT-disabled // * @since v16.5.0 // DT-disabled // */ // DT-disabled // keepAlive?: boolean | undefined; // DT-disabled // /** // DT-disabled // * If set to a positive number, it sets the initial delay before the first keepalive probe is sent on an idle socket. // DT-disabled // * @default 0 // DT-disabled // * @since v16.5.0 // DT-disabled // */ // DT-disabled // keepAliveInitialDelay?: number | undefined; // DT-disabled // /** // DT-disabled // * Optionally overrides all `net.Socket`s' `readableHighWaterMark` and `writableHighWaterMark`. // DT-disabled // * @default See [stream.getDefaultHighWaterMark()](https://nodejs.org/docs/latest-v22.x/api/stream.html#streamgetdefaulthighwatermarkobjectmode). // DT-disabled // * @since v18.17.0, v20.1.0 // DT-disabled // */ // DT-disabled // highWaterMark?: number | undefined; // DT-disabled // /** // DT-disabled // * `blockList` can be used for disabling inbound // DT-disabled // * access to specific IP addresses, IP ranges, or IP subnets. This does not // DT-disabled // * work if the server is behind a reverse proxy, NAT, etc. because the address // DT-disabled // * checked against the block list is the address of the proxy, or the one // DT-disabled // * specified by the NAT. // DT-disabled // * @since v22.13.0 // DT-disabled // */ // DT-disabled // // DT-disabled // blockList?: BlockList | undefined; // DT-disabled // } // DT-disabled // interface DropArgument { // DT-disabled // localAddress?: string; // DT-disabled // localPort?: number; // DT-disabled // localFamily?: string; // DT-disabled // remoteAddress?: string; // DT-disabled // remotePort?: number; // DT-disabled // remoteFamily?: string; // DT-disabled // } // DT-disabled // /** // DT-disabled // * This class is used to create a TCP or `IPC` server. // DT-disabled // * @since v0.1.90 // DT-disabled // */ // DT-disabled // class Server extends EventEmitter { // DT-disabled // constructor(connectionListener?: (socket: Socket) => void); // DT-disabled // constructor(options?: ServerOpts, connectionListener?: (socket: Socket) => void); // DT-disabled // /** // DT-disabled // * Start a server listening for connections. A `net.Server` can be a TCP or // DT-disabled // * an `IPC` server depending on what it listens to. // DT-disabled // * // DT-disabled // * Possible signatures: // DT-disabled // * // DT-disabled // * * `server.listen(handle[, backlog][, callback])` // DT-disabled // * * `server.listen(options[, callback])` // DT-disabled // * * `server.listen(path[, backlog][, callback])` for `IPC` servers // DT-disabled // * * `server.listen([port[, host[, backlog]]][, callback])` for TCP servers // DT-disabled // * // DT-disabled // * This function is asynchronous. When the server starts listening, the `'listening'` event will be emitted. The last parameter `callback`will be added as a listener for the `'listening'` // DT-disabled // * event. // DT-disabled // * // DT-disabled // * All `listen()` methods can take a `backlog` parameter to specify the maximum // DT-disabled // * length of the queue of pending connections. The actual length will be determined // DT-disabled // * by the OS through sysctl settings such as `tcp_max_syn_backlog` and `somaxconn` on Linux. The default value of this parameter is 511 (not 512). // DT-disabled // * // DT-disabled // * All {@link Socket} are set to `SO_REUSEADDR` (see [`socket(7)`](https://man7.org/linux/man-pages/man7/socket.7.html) for // DT-disabled // * details). // DT-disabled // * // DT-disabled // * The `server.listen()` method can be called again if and only if there was an // DT-disabled // * error during the first `server.listen()` call or `server.close()` has been // DT-disabled // * called. Otherwise, an `ERR_SERVER_ALREADY_LISTEN` error will be thrown. // DT-disabled // * // DT-disabled // * One of the most common errors raised when listening is `EADDRINUSE`. // DT-disabled // * This happens when another server is already listening on the requested`port`/`path`/`handle`. One way to handle this would be to retry // DT-disabled // * after a certain amount of time: // DT-disabled // * // DT-disabled // * ```js // DT-disabled // * server.on('error', (e) => { // DT-disabled // * if (e.code === 'EADDRINUSE') { // DT-disabled // * console.error('Address in use, retrying...'); // DT-disabled // * setTimeout(() => { // DT-disabled // * server.close(); // DT-disabled // * server.listen(PORT, HOST); // DT-disabled // * }, 1000); // DT-disabled // * } // DT-disabled // * }); // DT-disabled // * ``` // DT-disabled // */ // DT-disabled // listen(port?: number, hostname?: string, backlog?: number, listeningListener?: () => void): this; // DT-disabled // listen(port?: number, hostname?: string, listeningListener?: () => void): this; // DT-disabled // listen(port?: number, backlog?: number, listeningListener?: () => void): this; // DT-disabled // listen(port?: number, listeningListener?: () => void): this; // DT-disabled // listen(path: string, backlog?: number, listeningListener?: () => void): this; // DT-disabled // listen(path: string, listeningListener?: () => void): this; // DT-disabled // listen(options: ListenOptions, listeningListener?: () => void): this; // DT-disabled // listen(handle: any, backlog?: number, listeningListener?: () => void): this; // DT-disabled // listen(handle: any, listeningListener?: () => void): this; // DT-disabled // /** // DT-disabled // * Stops the server from accepting new connections and keeps existing // DT-disabled // * connections. This function is asynchronous, the server is finally closed // DT-disabled // * when all connections are ended and the server emits a `'close'` event. // DT-disabled // * The optional `callback` will be called once the `'close'` event occurs. Unlike // DT-disabled // * that event, it will be called with an `Error` as its only argument if the server // DT-disabled // * was not open when it was closed. // DT-disabled // * @since v0.1.90 // DT-disabled // * @param callback Called when the server is closed. // DT-disabled // */ // DT-disabled // close(callback?: (err?: Error) => void): this; // DT-disabled // /** // DT-disabled // * Returns the bound `address`, the address `family` name, and `port` of the server // DT-disabled // * as reported by the operating system if listening on an IP socket // DT-disabled // * (useful to find which port was assigned when getting an OS-assigned address):`{ port: 12346, family: 'IPv4', address: '127.0.0.1' }`. // DT-disabled // * // DT-disabled // * For a server listening on a pipe or Unix domain socket, the name is returned // DT-disabled // * as a string. // DT-disabled // * // DT-disabled // * ```js // DT-disabled // * const server = net.createServer((socket) => { // DT-disabled // * socket.end('goodbye\n'); // DT-disabled // * }).on('error', (err) => { // DT-disabled // * // Handle errors here. // DT-disabled // * throw err; // DT-disabled // * }); // DT-disabled // * // DT-disabled // * // Grab an arbitrary unused port. // DT-disabled // * server.listen(() => { // DT-disabled // * console.log('opened server on', server.address()); // DT-disabled // * }); // DT-disabled // * ``` // DT-disabled // * // DT-disabled // * `server.address()` returns `null` before the `'listening'` event has been // DT-disabled // * emitted or after calling `server.close()`. // DT-disabled // * @since v0.1.90 // DT-disabled // */ // DT-disabled // address(): AddressInfo | string | null; // DT-disabled // /** // DT-disabled // * Asynchronously get the number of concurrent connections on the server. Works // DT-disabled // * when sockets were sent to forks. // DT-disabled // * // DT-disabled // * Callback should take two arguments `err` and `count`. // DT-disabled // * @since v0.9.7 // DT-disabled // */ // DT-disabled // getConnections(cb: (error: Error | null, count: number) => void): void; // DT-disabled // /** // DT-disabled // * Opposite of `unref()`, calling `ref()` on a previously `unref`ed server will _not_ let the program exit if it's the only server left (the default behavior). // DT-disabled // * If the server is `ref`ed calling `ref()` again will have no effect. // DT-disabled // * @since v0.9.1 // DT-disabled // */ // DT-disabled // ref(): this; // DT-disabled // /** // DT-disabled // * Calling `unref()` on a server will allow the program to exit if this is the only // DT-disabled // * active server in the event system. If the server is already `unref`ed calling`unref()` again will have no effect. // DT-disabled // * @since v0.9.1 // DT-disabled // */ // DT-disabled // unref(): this; // DT-disabled // /** // DT-disabled // * Set this property to reject connections when the server's connection count gets // DT-disabled // * high. // DT-disabled // * // DT-disabled // * It is not recommended to use this option once a socket has been sent to a child // DT-disabled // * with `child_process.fork()`. // DT-disabled // * @since v0.2.0 // DT-disabled // */ // DT-disabled // maxConnections: number; // DT-disabled // connections: number; // DT-disabled // /** // DT-disabled // * Indicates whether or not the server is listening for connections. // DT-disabled // * @since v5.7.0 // DT-disabled // */ // DT-disabled // readonly listening: boolean; // DT-disabled // /** // DT-disabled // * events.EventEmitter // DT-disabled // * 1. close // DT-disabled // * 2. connection // DT-disabled // * 3. error // DT-disabled // * 4. listening // DT-disabled // * 5. drop // DT-disabled // */ // DT-disabled // addListener(event: string, listener: (...args: any[]) => void): this; // DT-disabled // addListener(event: "close", listener: () => void): this; // DT-disabled // addListener(event: "connection", listener: (socket: Socket) => void): this; // DT-disabled // addListener(event: "error", listener: (err: Error) => void): this; // DT-disabled // addListener(event: "listening", listener: () => void): this; // DT-disabled // addListener(event: "drop", listener: (data?: DropArgument) => void): this; // DT-disabled // emit(event: string | symbol, ...args: any[]): boolean; // DT-disabled // emit(event: "close"): boolean; // DT-disabled // emit(event: "connection", socket: Socket): boolean; // DT-disabled // emit(event: "error", err: Error): boolean; // DT-disabled // emit(event: "listening"): boolean; // DT-disabled // emit(event: "drop", data?: DropArgument): boolean; // DT-disabled // on(event: string, listener: (...args: any[]) => void): this; // DT-disabled // on(event: "close", listener: () => void): this; // DT-disabled // on(event: "connection", listener: (socket: Socket) => void): this; // DT-disabled // on(event: "error", listener: (err: Error) => void): this; // DT-disabled // on(event: "listening", listener: () => void): this; // DT-disabled // on(event: "drop", listener: (data?: DropArgument) => void): this; // DT-disabled // once(event: string, listener: (...args: any[]) => void): this; // DT-disabled // once(event: "close", listener: () => void): this; // DT-disabled // once(event: "connection", listener: (socket: Socket) => void): this; // DT-disabled // once(event: "error", listener: (err: Error) => void): this; // DT-disabled // once(event: "listening", listener: () => void): this; // DT-disabled // once(event: "drop", listener: (data?: DropArgument) => void): this; // DT-disabled // prependListener(event: string, listener: (...args: any[]) => void): this; // DT-disabled // prependListener(event: "close", listener: () => void): this; // DT-disabled // prependListener(event: "connection", listener: (socket: Socket) => void): this; // DT-disabled // prependListener(event: "error", listener: (err: Error) => void): this; // DT-disabled // prependListener(event: "listening", listener: () => void): this; // DT-disabled // prependListener(event: "drop", listener: (data?: DropArgument) => void): this; // DT-disabled // prependOnceListener(event: string, listener: (...args: any[]) => void): this; // DT-disabled // prependOnceListener(event: "close", listener: () => void): this; // DT-disabled // prependOnceListener(event: "connection", listener: (socket: Socket) => void): this; // DT-disabled // prependOnceListener(event: "error", listener: (err: Error) => void): this; // DT-disabled // prependOnceListener(event: "listening", listener: () => void): this; // DT-disabled // prependOnceListener(event: "drop", listener: (data?: DropArgument) => void): this; // DT-disabled // /** // DT-disabled // * Calls {@link Server.close()} and returns a promise that fulfills when the server has closed. // DT-disabled // * @since v20.5.0 // DT-disabled // */ // DT-disabled // [Symbol.asyncDispose](): Promise<void>; // DT-disabled // } // DT-disabled // type IPVersion = "ipv4" | "ipv6"; // DT-disabled // /** // DT-disabled // // DT-disabled // * The `BlockList` object can be used with some network APIs to specify rules for // DT-disabled // * disabling inbound or outbound access to specific IP addresses, IP ranges, or // DT-disabled // * IP subnets. // DT-disabled // * @since v15.0.0, v14.18.0 // DT-disabled // */ // DT-disabled // // DT-disabled // class BlockList { // DT-disabled // /** // DT-disabled // * Adds a rule to block the given IP address. // DT-disabled // * @since v15.0.0, v14.18.0 // DT-disabled // * @param address An IPv4 or IPv6 address. // DT-disabled // * @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`. // DT-disabled // */ // DT-disabled // addAddress(address: string, type?: IPVersion): void; // DT-disabled // addAddress(address: SocketAddress): void; // DT-disabled // /** // DT-disabled // * Adds a rule to block a range of IP addresses from `start` (inclusive) to`end` (inclusive). // DT-disabled // * @since v15.0.0, v14.18.0 // DT-disabled // * @param start The starting IPv4 or IPv6 address in the range. // DT-disabled // * @param end The ending IPv4 or IPv6 address in the range. // DT-disabled // * @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`. // DT-disabled // */ // DT-disabled // addRange(start: string, end: string, type?: IPVersion): void; // DT-disabled // addRange(start: SocketAddress, end: SocketAddress): void; // DT-disabled // /** // DT-disabled // * Adds a rule to block a range of IP addresses specified as a subnet mask. // DT-disabled // * @since v15.0.0, v14.18.0 // DT-disabled // * @param net The network IPv4 or IPv6 address. // DT-disabled // * @param prefix The number of CIDR prefix bits. For IPv4, this must be a value between `0` and `32`. For IPv6, this must be between `0` and `128`. // DT-disabled // * @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`. // DT-disabled // */ // DT-disabled // addSubnet(net: SocketAddress, prefix: number): void; // DT-disabled // addSubnet(net: string, prefix: number, type?: IPVersion): void; // DT-disabled // /** // DT-disabled // // DT-disabled // * Returns `true` if the given IP address matches any of the rules added to the`BlockList`. // DT-disabled // * // DT-disabled // * ```js // DT-disabled // // DT-disabled // * const blockList = new net.BlockList(); // DT-disabled // * blockList.addAddress('123.123.123.123'); // DT-disabled // * blockList.addRange('10.0.0.1', '10.0.0.10'); // DT-disabled // * blockList.addSubnet('8592:757c:efae:4e45::', 64, 'ipv6'); // DT-disabled // * // DT-disabled // * console.log(blockList.check('123.123.123.123')); // Prints: true // DT-disabled // * console.log(blockList.check('10.0.0.3')); // Prints: true // DT-disabled // * console.log(blockList.check('222.111.111.222')); // Prints: false // DT-disabled // * // DT-disabled // * // IPv6 notation for IPv4 addresses works: // DT-disabled // * console.log(blockList.check('::ffff:7b7b:7b7b', 'ipv6')); // Prints: true // DT-disabled // * console.log(blockList.check('::ffff:123.123.123.123', 'ipv6')); // Prints: true // DT-disabled // * ``` // DT-disabled // * @since v15.0.0, v14.18.0 // DT-disabled // * @param address The IP address to check // DT-disabled // * @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`. // DT-disabled // */ // DT-disabled // check(address: SocketAddress): boolean; // DT-disabled // check(address: string, type?: IPVersion): boolean; // DT-disabled // /** // DT-disabled // * The list of rules added to the blocklist. // DT-disabled // * @since v15.0.0, v14.18.0 // DT-disabled // */ // DT-disabled // rules: readonly string[]; // DT-disabled // /** // DT-disabled // // DT-disabled // * Returns `true` if the `value` is a `net.BlockList`. // DT-disabled // * @since v22.13.0 // DT-disabled // * @param value Any JS value // DT-disabled // */ // DT-disabled // // DT-disabled // static isBlockList(value: unknown): value is BlockList; // DT-disabled // } // DT-disabled // interface TcpNetConnectOpts extends TcpSocketConnectOpts, SocketConstructorOpts { // DT-disabled // timeout?: number | undefined; // DT-disabled // } // DT-disabled // interface IpcNetConnectOpts extends IpcSocketConnectOpts, SocketConstructorOpts { // DT-disabled // timeout?: number | undefined; // DT-disabled // } // DT-disabled // type NetConnectOpts = TcpNetConnectOpts | IpcNetConnectOpts; // DT-disabled // /** // DT-disabled // * Creates a new TCP or `IPC` server. // DT-disabled // * // DT-disabled // * If `allowHalfOpen` is set to `true`, when the other end of the socket // DT-disabled // * signals the end of transmission, the server will only send back the end of // DT-disabled // * transmission when `socket.end()` is explicitly called. For example, in the // DT-disabled // * context of TCP, when a FIN packed is received, a FIN packed is sent // DT-disabled // * back only when `socket.end()` is explicitly called. Until then the // DT-disabled // * connection is half-closed (non-readable but still writable). See `'end'` event and [RFC 1122](https://tools.ietf.org/html/rfc1122) (section 4.2.2.13) for more information. // DT-disabled // * // DT-disabled // * If `pauseOnConnect` is set to `true`, then the socket associated with each // DT-disabled // * incoming connection will be paused, and no data will be read from its handle. // DT-disabled // * This allows connections to be passed between processes without any data being // DT-disabled // * read by the original process. To begin reading data from a paused socket, call `socket.resume()`. // DT-disabled // * // DT-disabled // * The server can be a TCP server or an `IPC` server, depending on what it `listen()` to. // DT-disabled // * // DT-disabled // * Here is an example of a TCP echo server which listens for connections // DT-disabled // * on port 8124: // DT-disabled // * // DT-disabled // * ```js // DT-disabled // * import net from 'node:net'; // DT-disabled // * const server = net.createServer((c) => { // DT-disabled // * // 'connection' listener. // DT-disabled // * console.log('client connected'); // DT-disabled // * c.on('end', () => { // DT-disabled // * console.log('client disconnected'); // DT-disabled // * }); // DT-disabled // * c.write('hello\r\n'); // DT-disabled // * c.pipe(c); // DT-disabled // * }); // DT-disabled // * server.on('error', (err) => { // DT-disabled // * throw err; // DT-disabled // * }); // DT-disabled // * server.listen(8124, () => { // DT-disabled // * console.log('server bound'); // DT-disabled // * }); // DT-disabled // * ``` // DT-disabled // * // DT-disabled // * Test this by using `telnet`: // DT-disabled // * // DT-disabled // * ```bash // DT-disabled // * telnet localhost 8124 // DT-disabled // * ``` // DT-disabled // * // DT-disabled // * To listen on the socket `/tmp/echo.sock`: // DT-disabled // * // DT-disabled // * ```js // DT-disabled // * server.listen('/tmp/echo.sock', () => { // DT-disabled // * console.log('server bound'); // DT-disabled // * }); // DT-disabled // * ``` // DT-disabled // * // DT-disabled // * Use `nc` to connect to a Unix domain socket server: // DT-disabled // * // DT-disabled // * ```bash // DT-disabled // * nc -U /tmp/echo.sock // DT-disabled // * ``` // DT-disabled // * @since v0.5.0 // DT-disabled // * @param connectionListener Automatically set as a listener for the {@link 'connection'} event. // DT-disabled // */ // DT-disabled // function createServer(connectionListener?: (socket: Socket) => void): Server; // DT-disabled // function createServer(options?: ServerOpts, connectionListener?: (socket: Socket) => void): Server; // DT-disabled // /** // DT-disabled // * Aliases to {@link createConnection}. // DT-disabled // * // DT-disabled // * Possible signatures: // DT-disabled // * // DT-disabled // * * {@link connect} // DT-disabled // * * {@link connect} for `IPC` connections. // DT-disabled // * * {@link connect} for TCP connections. // DT-disabled // */ // DT-disabled // function connect(options: NetConnectOpts, connectionListener?: () => void): Socket; // DT-disabled // function connect(port: number, host?: string, connectionListener?: () => void): Socket; // DT-disabled // function connect(path: string, connectionListener?: () => void): Socket; // DT-disabled // /** // DT-disabled // * A fac