rahad-all-downloader 2.1.15 → 2.1.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (186) hide show
  1. package/.github/workflows/Run.yml +20 -0
  2. package/README.md +0 -1
  3. package/index.js +1 -1
  4. package/package.json +4 -2
  5. package/.cache/nix/binary-cache-v6.sqlite +0 -0
  6. package/.cache/nix/binary-cache-v6.sqlite-journal +0 -0
  7. package/.cache/replit/modules/nix.res +0 -1
  8. package/.cache/replit/modules/nodejs-20.res +0 -1
  9. package/.cache/replit/modules/replit.res +0 -1
  10. package/.cache/replit/modules.stamp +0 -0
  11. package/.cache/replit/nix/env.json +0 -1
  12. package/.cache/typescript/5.4/node_modules/.package-lock.json +0 -137
  13. package/.cache/typescript/5.4/node_modules/@types/caseless/LICENSE +0 -21
  14. package/.cache/typescript/5.4/node_modules/@types/caseless/README.md +0 -48
  15. package/.cache/typescript/5.4/node_modules/@types/caseless/index.d.ts +0 -29
  16. package/.cache/typescript/5.4/node_modules/@types/caseless/package.json +0 -35
  17. package/.cache/typescript/5.4/node_modules/@types/node/LICENSE +0 -21
  18. package/.cache/typescript/5.4/node_modules/@types/node/README.md +0 -15
  19. package/.cache/typescript/5.4/node_modules/@types/node/assert/strict.d.ts +0 -8
  20. package/.cache/typescript/5.4/node_modules/@types/node/assert.d.ts +0 -1040
  21. package/.cache/typescript/5.4/node_modules/@types/node/async_hooks.d.ts +0 -541
  22. package/.cache/typescript/5.4/node_modules/@types/node/buffer.d.ts +0 -2363
  23. package/.cache/typescript/5.4/node_modules/@types/node/child_process.d.ts +0 -1544
  24. package/.cache/typescript/5.4/node_modules/@types/node/cluster.d.ts +0 -578
  25. package/.cache/typescript/5.4/node_modules/@types/node/console.d.ts +0 -452
  26. package/.cache/typescript/5.4/node_modules/@types/node/constants.d.ts +0 -19
  27. package/.cache/typescript/5.4/node_modules/@types/node/crypto.d.ts +0 -4523
  28. package/.cache/typescript/5.4/node_modules/@types/node/dgram.d.ts +0 -596
  29. package/.cache/typescript/5.4/node_modules/@types/node/diagnostics_channel.d.ts +0 -554
  30. package/.cache/typescript/5.4/node_modules/@types/node/dns/promises.d.ts +0 -474
  31. package/.cache/typescript/5.4/node_modules/@types/node/dns.d.ts +0 -864
  32. package/.cache/typescript/5.4/node_modules/@types/node/dom-events.d.ts +0 -124
  33. package/.cache/typescript/5.4/node_modules/@types/node/domain.d.ts +0 -170
  34. package/.cache/typescript/5.4/node_modules/@types/node/events.d.ts +0 -909
  35. package/.cache/typescript/5.4/node_modules/@types/node/fs/promises.d.ts +0 -1245
  36. package/.cache/typescript/5.4/node_modules/@types/node/fs.d.ts +0 -4317
  37. package/.cache/typescript/5.4/node_modules/@types/node/globals.d.ts +0 -411
  38. package/.cache/typescript/5.4/node_modules/@types/node/globals.global.d.ts +0 -1
  39. package/.cache/typescript/5.4/node_modules/@types/node/http.d.ts +0 -1908
  40. package/.cache/typescript/5.4/node_modules/@types/node/http2.d.ts +0 -2418
  41. package/.cache/typescript/5.4/node_modules/@types/node/https.d.ts +0 -550
  42. package/.cache/typescript/5.4/node_modules/@types/node/index.d.ts +0 -89
  43. package/.cache/typescript/5.4/node_modules/@types/node/inspector.d.ts +0 -2746
  44. package/.cache/typescript/5.4/node_modules/@types/node/module.d.ts +0 -315
  45. package/.cache/typescript/5.4/node_modules/@types/node/net.d.ts +0 -999
  46. package/.cache/typescript/5.4/node_modules/@types/node/os.d.ts +0 -495
  47. package/.cache/typescript/5.4/node_modules/@types/node/package.json +0 -217
  48. package/.cache/typescript/5.4/node_modules/@types/node/path.d.ts +0 -191
  49. package/.cache/typescript/5.4/node_modules/@types/node/perf_hooks.d.ts +0 -905
  50. package/.cache/typescript/5.4/node_modules/@types/node/process.d.ts +0 -1754
  51. package/.cache/typescript/5.4/node_modules/@types/node/punycode.d.ts +0 -117
  52. package/.cache/typescript/5.4/node_modules/@types/node/querystring.d.ts +0 -153
  53. package/.cache/typescript/5.4/node_modules/@types/node/readline/promises.d.ts +0 -150
  54. package/.cache/typescript/5.4/node_modules/@types/node/readline.d.ts +0 -540
  55. package/.cache/typescript/5.4/node_modules/@types/node/repl.d.ts +0 -430
  56. package/.cache/typescript/5.4/node_modules/@types/node/sea.d.ts +0 -153
  57. package/.cache/typescript/5.4/node_modules/@types/node/stream/consumers.d.ts +0 -12
  58. package/.cache/typescript/5.4/node_modules/@types/node/stream/promises.d.ts +0 -83
  59. package/.cache/typescript/5.4/node_modules/@types/node/stream/web.d.ts +0 -367
  60. package/.cache/typescript/5.4/node_modules/@types/node/stream.d.ts +0 -1707
  61. package/.cache/typescript/5.4/node_modules/@types/node/string_decoder.d.ts +0 -67
  62. package/.cache/typescript/5.4/node_modules/@types/node/test.d.ts +0 -1718
  63. package/.cache/typescript/5.4/node_modules/@types/node/timers/promises.d.ts +0 -97
  64. package/.cache/typescript/5.4/node_modules/@types/node/timers.d.ts +0 -240
  65. package/.cache/typescript/5.4/node_modules/@types/node/tls.d.ts +0 -1217
  66. package/.cache/typescript/5.4/node_modules/@types/node/trace_events.d.ts +0 -197
  67. package/.cache/typescript/5.4/node_modules/@types/node/tty.d.ts +0 -208
  68. package/.cache/typescript/5.4/node_modules/@types/node/url.d.ts +0 -952
  69. package/.cache/typescript/5.4/node_modules/@types/node/util.d.ts +0 -2292
  70. package/.cache/typescript/5.4/node_modules/@types/node/v8.d.ts +0 -808
  71. package/.cache/typescript/5.4/node_modules/@types/node/vm.d.ts +0 -924
  72. package/.cache/typescript/5.4/node_modules/@types/node/wasi.d.ts +0 -181
  73. package/.cache/typescript/5.4/node_modules/@types/node/worker_threads.d.ts +0 -691
  74. package/.cache/typescript/5.4/node_modules/@types/node/zlib.d.ts +0 -530
  75. package/.cache/typescript/5.4/node_modules/@types/node-fetch/LICENSE +0 -21
  76. package/.cache/typescript/5.4/node_modules/@types/node-fetch/README.md +0 -15
  77. package/.cache/typescript/5.4/node_modules/@types/node-fetch/externals.d.ts +0 -32
  78. package/.cache/typescript/5.4/node_modules/@types/node-fetch/index.d.ts +0 -238
  79. package/.cache/typescript/5.4/node_modules/@types/node-fetch/package.json +0 -83
  80. package/.cache/typescript/5.4/node_modules/@types/request/LICENSE +0 -21
  81. package/.cache/typescript/5.4/node_modules/@types/request/README.md +0 -15
  82. package/.cache/typescript/5.4/node_modules/@types/request/index.d.ts +0 -395
  83. package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/License +0 -19
  84. package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/README.md +0 -350
  85. package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/README.md.bak +0 -350
  86. package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/index.d.ts +0 -51
  87. package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/lib/browser.js +0 -2
  88. package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/lib/form_data.js +0 -483
  89. package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/lib/populate.js +0 -10
  90. package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/package.json +0 -68
  91. package/.cache/typescript/5.4/node_modules/@types/request/package.json +0 -70
  92. package/.cache/typescript/5.4/node_modules/@types/tough-cookie/LICENSE +0 -21
  93. package/.cache/typescript/5.4/node_modules/@types/tough-cookie/README.md +0 -15
  94. package/.cache/typescript/5.4/node_modules/@types/tough-cookie/index.d.ts +0 -321
  95. package/.cache/typescript/5.4/node_modules/@types/tough-cookie/package.json +0 -35
  96. package/.cache/typescript/5.4/node_modules/asynckit/LICENSE +0 -21
  97. package/.cache/typescript/5.4/node_modules/asynckit/README.md +0 -233
  98. package/.cache/typescript/5.4/node_modules/asynckit/bench.js +0 -76
  99. package/.cache/typescript/5.4/node_modules/asynckit/index.js +0 -6
  100. package/.cache/typescript/5.4/node_modules/asynckit/lib/abort.js +0 -29
  101. package/.cache/typescript/5.4/node_modules/asynckit/lib/async.js +0 -34
  102. package/.cache/typescript/5.4/node_modules/asynckit/lib/defer.js +0 -26
  103. package/.cache/typescript/5.4/node_modules/asynckit/lib/iterate.js +0 -75
  104. package/.cache/typescript/5.4/node_modules/asynckit/lib/readable_asynckit.js +0 -91
  105. package/.cache/typescript/5.4/node_modules/asynckit/lib/readable_parallel.js +0 -25
  106. package/.cache/typescript/5.4/node_modules/asynckit/lib/readable_serial.js +0 -25
  107. package/.cache/typescript/5.4/node_modules/asynckit/lib/readable_serial_ordered.js +0 -29
  108. package/.cache/typescript/5.4/node_modules/asynckit/lib/state.js +0 -37
  109. package/.cache/typescript/5.4/node_modules/asynckit/lib/streamify.js +0 -141
  110. package/.cache/typescript/5.4/node_modules/asynckit/lib/terminator.js +0 -29
  111. package/.cache/typescript/5.4/node_modules/asynckit/package.json +0 -63
  112. package/.cache/typescript/5.4/node_modules/asynckit/parallel.js +0 -43
  113. package/.cache/typescript/5.4/node_modules/asynckit/serial.js +0 -17
  114. package/.cache/typescript/5.4/node_modules/asynckit/serialOrdered.js +0 -75
  115. package/.cache/typescript/5.4/node_modules/asynckit/stream.js +0 -21
  116. package/.cache/typescript/5.4/node_modules/combined-stream/License +0 -19
  117. package/.cache/typescript/5.4/node_modules/combined-stream/Readme.md +0 -138
  118. package/.cache/typescript/5.4/node_modules/combined-stream/lib/combined_stream.js +0 -208
  119. package/.cache/typescript/5.4/node_modules/combined-stream/package.json +0 -25
  120. package/.cache/typescript/5.4/node_modules/combined-stream/yarn.lock +0 -17
  121. package/.cache/typescript/5.4/node_modules/delayed-stream/License +0 -19
  122. package/.cache/typescript/5.4/node_modules/delayed-stream/Makefile +0 -7
  123. package/.cache/typescript/5.4/node_modules/delayed-stream/Readme.md +0 -141
  124. package/.cache/typescript/5.4/node_modules/delayed-stream/lib/delayed_stream.js +0 -107
  125. package/.cache/typescript/5.4/node_modules/delayed-stream/package.json +0 -27
  126. package/.cache/typescript/5.4/node_modules/form-data/License +0 -19
  127. package/.cache/typescript/5.4/node_modules/form-data/README.md.bak +0 -358
  128. package/.cache/typescript/5.4/node_modules/form-data/Readme.md +0 -358
  129. package/.cache/typescript/5.4/node_modules/form-data/index.d.ts +0 -62
  130. package/.cache/typescript/5.4/node_modules/form-data/lib/browser.js +0 -2
  131. package/.cache/typescript/5.4/node_modules/form-data/lib/form_data.js +0 -501
  132. package/.cache/typescript/5.4/node_modules/form-data/lib/populate.js +0 -10
  133. package/.cache/typescript/5.4/node_modules/form-data/package.json +0 -68
  134. package/.cache/typescript/5.4/node_modules/mime-db/HISTORY.md +0 -507
  135. package/.cache/typescript/5.4/node_modules/mime-db/LICENSE +0 -23
  136. package/.cache/typescript/5.4/node_modules/mime-db/README.md +0 -100
  137. package/.cache/typescript/5.4/node_modules/mime-db/db.json +0 -8519
  138. package/.cache/typescript/5.4/node_modules/mime-db/index.js +0 -12
  139. package/.cache/typescript/5.4/node_modules/mime-db/package.json +0 -60
  140. package/.cache/typescript/5.4/node_modules/mime-types/HISTORY.md +0 -397
  141. package/.cache/typescript/5.4/node_modules/mime-types/LICENSE +0 -23
  142. package/.cache/typescript/5.4/node_modules/mime-types/README.md +0 -113
  143. package/.cache/typescript/5.4/node_modules/mime-types/index.js +0 -188
  144. package/.cache/typescript/5.4/node_modules/mime-types/package.json +0 -44
  145. package/.cache/typescript/5.4/node_modules/types-registry/README.md +0 -2
  146. package/.cache/typescript/5.4/node_modules/types-registry/index.json +0 -1
  147. package/.cache/typescript/5.4/node_modules/types-registry/package.json +0 -20
  148. package/.cache/typescript/5.4/node_modules/undici-types/README.md +0 -6
  149. package/.cache/typescript/5.4/node_modules/undici-types/agent.d.ts +0 -31
  150. package/.cache/typescript/5.4/node_modules/undici-types/api.d.ts +0 -43
  151. package/.cache/typescript/5.4/node_modules/undici-types/balanced-pool.d.ts +0 -18
  152. package/.cache/typescript/5.4/node_modules/undici-types/cache.d.ts +0 -36
  153. package/.cache/typescript/5.4/node_modules/undici-types/client.d.ts +0 -97
  154. package/.cache/typescript/5.4/node_modules/undici-types/connector.d.ts +0 -34
  155. package/.cache/typescript/5.4/node_modules/undici-types/content-type.d.ts +0 -21
  156. package/.cache/typescript/5.4/node_modules/undici-types/cookies.d.ts +0 -28
  157. package/.cache/typescript/5.4/node_modules/undici-types/diagnostics-channel.d.ts +0 -67
  158. package/.cache/typescript/5.4/node_modules/undici-types/dispatcher.d.ts +0 -241
  159. package/.cache/typescript/5.4/node_modules/undici-types/errors.d.ts +0 -128
  160. package/.cache/typescript/5.4/node_modules/undici-types/fetch.d.ts +0 -209
  161. package/.cache/typescript/5.4/node_modules/undici-types/file.d.ts +0 -39
  162. package/.cache/typescript/5.4/node_modules/undici-types/filereader.d.ts +0 -54
  163. package/.cache/typescript/5.4/node_modules/undici-types/formdata.d.ts +0 -108
  164. package/.cache/typescript/5.4/node_modules/undici-types/global-dispatcher.d.ts +0 -9
  165. package/.cache/typescript/5.4/node_modules/undici-types/global-origin.d.ts +0 -7
  166. package/.cache/typescript/5.4/node_modules/undici-types/handlers.d.ts +0 -9
  167. package/.cache/typescript/5.4/node_modules/undici-types/header.d.ts +0 -4
  168. package/.cache/typescript/5.4/node_modules/undici-types/index.d.ts +0 -63
  169. package/.cache/typescript/5.4/node_modules/undici-types/interceptors.d.ts +0 -5
  170. package/.cache/typescript/5.4/node_modules/undici-types/mock-agent.d.ts +0 -50
  171. package/.cache/typescript/5.4/node_modules/undici-types/mock-client.d.ts +0 -25
  172. package/.cache/typescript/5.4/node_modules/undici-types/mock-errors.d.ts +0 -12
  173. package/.cache/typescript/5.4/node_modules/undici-types/mock-interceptor.d.ts +0 -93
  174. package/.cache/typescript/5.4/node_modules/undici-types/mock-pool.d.ts +0 -25
  175. package/.cache/typescript/5.4/node_modules/undici-types/package.json +0 -55
  176. package/.cache/typescript/5.4/node_modules/undici-types/patch.d.ts +0 -71
  177. package/.cache/typescript/5.4/node_modules/undici-types/pool-stats.d.ts +0 -19
  178. package/.cache/typescript/5.4/node_modules/undici-types/pool.d.ts +0 -28
  179. package/.cache/typescript/5.4/node_modules/undici-types/proxy-agent.d.ts +0 -30
  180. package/.cache/typescript/5.4/node_modules/undici-types/readable.d.ts +0 -61
  181. package/.cache/typescript/5.4/node_modules/undici-types/webidl.d.ts +0 -220
  182. package/.cache/typescript/5.4/node_modules/undici-types/websocket.d.ts +0 -131
  183. package/.cache/typescript/5.4/package-lock.json +0 -146
  184. package/.cache/typescript/5.4/package.json +0 -1
  185. package/.replit +0 -21
  186. package/replit.nix +0 -3
@@ -1,999 +0,0 @@
1
- /**
2
- * > Stability: 2 - Stable
3
- *
4
- * The `node:net` module provides an asynchronous network API for creating stream-based
5
- * TCP or `IPC` servers ({@link createServer}) and clients
6
- * ({@link createConnection}).
7
- *
8
- * It can be accessed using:
9
- *
10
- * ```js
11
- * const net = require('node:net');
12
- * ```
13
- * @see [source](https://github.com/nodejs/node/blob/v20.13.1/lib/net.js)
14
- */
15
- declare module "net" {
16
- import * as stream from "node:stream";
17
- import { Abortable, EventEmitter } from "node:events";
18
- import * as dns from "node:dns";
19
- type LookupFunction = (
20
- hostname: string,
21
- options: dns.LookupOptions,
22
- callback: (err: NodeJS.ErrnoException | null, address: string | dns.LookupAddress[], family?: number) => void,
23
- ) => void;
24
- interface AddressInfo {
25
- address: string;
26
- family: string;
27
- port: number;
28
- }
29
- interface SocketConstructorOpts {
30
- fd?: number | undefined;
31
- allowHalfOpen?: boolean | undefined;
32
- readable?: boolean | undefined;
33
- writable?: boolean | undefined;
34
- signal?: AbortSignal;
35
- }
36
- interface OnReadOpts {
37
- buffer: Uint8Array | (() => Uint8Array);
38
- /**
39
- * This function is called for every chunk of incoming data.
40
- * Two arguments are passed to it: the number of bytes written to buffer and a reference to buffer.
41
- * Return false from this function to implicitly pause() the socket.
42
- */
43
- callback(bytesWritten: number, buf: Uint8Array): boolean;
44
- }
45
- interface ConnectOpts {
46
- /**
47
- * If specified, incoming data is stored in a single buffer and passed to the supplied callback when data arrives on the socket.
48
- * Note: this will cause the streaming functionality to not provide any data, however events like 'error', 'end', and 'close' will
49
- * still be emitted as normal and methods like pause() and resume() will also behave as expected.
50
- */
51
- onread?: OnReadOpts | undefined;
52
- }
53
- interface TcpSocketConnectOpts extends ConnectOpts {
54
- port: number;
55
- host?: string | undefined;
56
- localAddress?: string | undefined;
57
- localPort?: number | undefined;
58
- hints?: number | undefined;
59
- family?: number | undefined;
60
- lookup?: LookupFunction | undefined;
61
- noDelay?: boolean | undefined;
62
- keepAlive?: boolean | undefined;
63
- keepAliveInitialDelay?: number | undefined;
64
- /**
65
- * @since v18.13.0
66
- */
67
- autoSelectFamily?: boolean | undefined;
68
- /**
69
- * @since v18.13.0
70
- */
71
- autoSelectFamilyAttemptTimeout?: number | undefined;
72
- }
73
- interface IpcSocketConnectOpts extends ConnectOpts {
74
- path: string;
75
- }
76
- type SocketConnectOpts = TcpSocketConnectOpts | IpcSocketConnectOpts;
77
- type SocketReadyState = "opening" | "open" | "readOnly" | "writeOnly" | "closed";
78
- /**
79
- * This class is an abstraction of a TCP socket or a streaming `IPC` endpoint
80
- * (uses named pipes on Windows, and Unix domain sockets otherwise). It is also
81
- * an `EventEmitter`.
82
- *
83
- * A `net.Socket` can be created by the user and used directly to interact with
84
- * a server. For example, it is returned by {@link createConnection},
85
- * so the user can use it to talk to the server.
86
- *
87
- * It can also be created by Node.js and passed to the user when a connection
88
- * is received. For example, it is passed to the listeners of a `'connection'` event emitted on a {@link Server}, so the user can use
89
- * it to interact with the client.
90
- * @since v0.3.4
91
- */
92
- class Socket extends stream.Duplex {
93
- constructor(options?: SocketConstructorOpts);
94
- /**
95
- * Destroys the socket after all data is written. If the `finish` event was already emitted the socket is destroyed immediately.
96
- * If the socket is still writable it implicitly calls `socket.end()`.
97
- * @since v0.3.4
98
- */
99
- destroySoon(): void;
100
- /**
101
- * Sends data on the socket. The second parameter specifies the encoding in the
102
- * case of a string. It defaults to UTF8 encoding.
103
- *
104
- * Returns `true` if the entire data was flushed successfully to the kernel
105
- * 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.
106
- *
107
- * The optional `callback` parameter will be executed when the data is finally
108
- * written out, which may not be immediately.
109
- *
110
- * See `Writable` stream `write()` method for more
111
- * information.
112
- * @since v0.1.90
113
- * @param [encoding='utf8'] Only used when data is `string`.
114
- */
115
- write(buffer: Uint8Array | string, cb?: (err?: Error) => void): boolean;
116
- write(str: Uint8Array | string, encoding?: BufferEncoding, cb?: (err?: Error) => void): boolean;
117
- /**
118
- * Initiate a connection on a given socket.
119
- *
120
- * Possible signatures:
121
- *
122
- * * `socket.connect(options[, connectListener])`
123
- * * `socket.connect(path[, connectListener])` for `IPC` connections.
124
- * * `socket.connect(port[, host][, connectListener])` for TCP connections.
125
- * * Returns: `net.Socket` The socket itself.
126
- *
127
- * This function is asynchronous. When the connection is established, the `'connect'` event will be emitted. If there is a problem connecting,
128
- * instead of a `'connect'` event, an `'error'` event will be emitted with
129
- * the error passed to the `'error'` listener.
130
- * The last parameter `connectListener`, if supplied, will be added as a listener
131
- * for the `'connect'` event **once**.
132
- *
133
- * This function should only be used for reconnecting a socket after`'close'` has been emitted or otherwise it may lead to undefined
134
- * behavior.
135
- */
136
- connect(options: SocketConnectOpts, connectionListener?: () => void): this;
137
- connect(port: number, host: string, connectionListener?: () => void): this;
138
- connect(port: number, connectionListener?: () => void): this;
139
- connect(path: string, connectionListener?: () => void): this;
140
- /**
141
- * Set the encoding for the socket as a `Readable Stream`. See `readable.setEncoding()` for more information.
142
- * @since v0.1.90
143
- * @return The socket itself.
144
- */
145
- setEncoding(encoding?: BufferEncoding): this;
146
- /**
147
- * Pauses the reading of data. That is, `'data'` events will not be emitted.
148
- * Useful to throttle back an upload.
149
- * @return The socket itself.
150
- */
151
- pause(): this;
152
- /**
153
- * Close the TCP connection by sending an RST packet and destroy the stream.
154
- * If this TCP socket is in connecting status, it will send an RST packet and destroy this TCP socket once it is connected.
155
- * Otherwise, it will call `socket.destroy` with an `ERR_SOCKET_CLOSED` Error.
156
- * If this is not a TCP socket (for example, a pipe), calling this method will immediately throw an `ERR_INVALID_HANDLE_TYPE` Error.
157
- * @since v18.3.0, v16.17.0
158
- */
159
- resetAndDestroy(): this;
160
- /**
161
- * Resumes reading after a call to `socket.pause()`.
162
- * @return The socket itself.
163
- */
164
- resume(): this;
165
- /**
166
- * Sets the socket to timeout after `timeout` milliseconds of inactivity on
167
- * the socket. By default `net.Socket` do not have a timeout.
168
- *
169
- * 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
170
- * end the connection.
171
- *
172
- * ```js
173
- * socket.setTimeout(3000);
174
- * socket.on('timeout', () => {
175
- * console.log('socket timeout');
176
- * socket.end();
177
- * });
178
- * ```
179
- *
180
- * If `timeout` is 0, then the existing idle timeout is disabled.
181
- *
182
- * The optional `callback` parameter will be added as a one-time listener for the `'timeout'` event.
183
- * @since v0.1.90
184
- * @return The socket itself.
185
- */
186
- setTimeout(timeout: number, callback?: () => void): this;
187
- /**
188
- * Enable/disable the use of Nagle's algorithm.
189
- *
190
- * When a TCP connection is created, it will have Nagle's algorithm enabled.
191
- *
192
- * Nagle's algorithm delays data before it is sent via the network. It attempts
193
- * to optimize throughput at the expense of latency.
194
- *
195
- * Passing `true` for `noDelay` or not passing an argument will disable Nagle's
196
- * algorithm for the socket. Passing `false` for `noDelay` will enable Nagle's
197
- * algorithm.
198
- * @since v0.1.90
199
- * @param [noDelay=true]
200
- * @return The socket itself.
201
- */
202
- setNoDelay(noDelay?: boolean): this;
203
- /**
204
- * Enable/disable keep-alive functionality, and optionally set the initial
205
- * delay before the first keepalive probe is sent on an idle socket.
206
- *
207
- * Set `initialDelay` (in milliseconds) to set the delay between the last
208
- * data packet received and the first keepalive probe. Setting `0` for`initialDelay` will leave the value unchanged from the default
209
- * (or previous) setting.
210
- *
211
- * Enabling the keep-alive functionality will set the following socket options:
212
- *
213
- * * `SO_KEEPALIVE=1`
214
- * * `TCP_KEEPIDLE=initialDelay`
215
- * * `TCP_KEEPCNT=10`
216
- * * `TCP_KEEPINTVL=1`
217
- * @since v0.1.92
218
- * @param [enable=false]
219
- * @param [initialDelay=0]
220
- * @return The socket itself.
221
- */
222
- setKeepAlive(enable?: boolean, initialDelay?: number): this;
223
- /**
224
- * Returns the bound `address`, the address `family` name and `port` of the
225
- * socket as reported by the operating system:`{ port: 12346, family: 'IPv4', address: '127.0.0.1' }`
226
- * @since v0.1.90
227
- */
228
- address(): AddressInfo | {};
229
- /**
230
- * Calling `unref()` on a socket will allow the program to exit if this is the only
231
- * active socket in the event system. If the socket is already `unref`ed calling`unref()` again will have no effect.
232
- * @since v0.9.1
233
- * @return The socket itself.
234
- */
235
- unref(): this;
236
- /**
237
- * 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).
238
- * If the socket is `ref`ed calling `ref` again will have no effect.
239
- * @since v0.9.1
240
- * @return The socket itself.
241
- */
242
- ref(): this;
243
- /**
244
- * This property is only present if the family autoselection algorithm is enabled in `socket.connect(options)`
245
- * and it is an array of the addresses that have been attempted.
246
- *
247
- * Each address is a string in the form of `$IP:$PORT`.
248
- * If the connection was successful, then the last address is the one that the socket is currently connected to.
249
- * @since v19.4.0
250
- */
251
- readonly autoSelectFamilyAttemptedAddresses: string[];
252
- /**
253
- * This property shows the number of characters buffered for writing. The buffer
254
- * may contain strings whose length after encoding is not yet known. So this number
255
- * is only an approximation of the number of bytes in the buffer.
256
- *
257
- * `net.Socket` has the property that `socket.write()` always works. This is to
258
- * help users get up and running quickly. The computer cannot always keep up
259
- * with the amount of data that is written to a socket. The network connection
260
- * simply might be too slow. Node.js will internally queue up the data written to a
261
- * socket and send it out over the wire when it is possible.
262
- *
263
- * The consequence of this internal buffering is that memory may grow.
264
- * Users who experience large or growing `bufferSize` should attempt to
265
- * "throttle" the data flows in their program with `socket.pause()` and `socket.resume()`.
266
- * @since v0.3.8
267
- * @deprecated Since v14.6.0 - Use `writableLength` instead.
268
- */
269
- readonly bufferSize: number;
270
- /**
271
- * The amount of received bytes.
272
- * @since v0.5.3
273
- */
274
- readonly bytesRead: number;
275
- /**
276
- * The amount of bytes sent.
277
- * @since v0.5.3
278
- */
279
- readonly bytesWritten: number;
280
- /**
281
- * If `true`, `socket.connect(options[, connectListener])` was
282
- * called and has not yet finished. It will stay `true` until the socket becomes
283
- * connected, then it is set to `false` and the `'connect'` event is emitted. Note
284
- * that the `socket.connect(options[, connectListener])` callback is a listener for the `'connect'` event.
285
- * @since v6.1.0
286
- */
287
- readonly connecting: boolean;
288
- /**
289
- * 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
290
- * (see `socket.connecting`).
291
- * @since v11.2.0, v10.16.0
292
- */
293
- readonly pending: boolean;
294
- /**
295
- * See `writable.destroyed` for further details.
296
- */
297
- readonly destroyed: boolean;
298
- /**
299
- * The string representation of the local IP address the remote client is
300
- * connecting on. For example, in a server listening on `'0.0.0.0'`, if a client
301
- * connects on `'192.168.1.1'`, the value of `socket.localAddress` would be`'192.168.1.1'`.
302
- * @since v0.9.6
303
- */
304
- readonly localAddress?: string;
305
- /**
306
- * The numeric representation of the local port. For example, `80` or `21`.
307
- * @since v0.9.6
308
- */
309
- readonly localPort?: number;
310
- /**
311
- * The string representation of the local IP family. `'IPv4'` or `'IPv6'`.
312
- * @since v18.8.0, v16.18.0
313
- */
314
- readonly localFamily?: string;
315
- /**
316
- * This property represents the state of the connection as a string.
317
- *
318
- * * If the stream is connecting `socket.readyState` is `opening`.
319
- * * If the stream is readable and writable, it is `open`.
320
- * * If the stream is readable and not writable, it is `readOnly`.
321
- * * If the stream is not readable and writable, it is `writeOnly`.
322
- * @since v0.5.0
323
- */
324
- readonly readyState: SocketReadyState;
325
- /**
326
- * The string representation of the remote IP address. For example,`'74.125.127.100'` or `'2001:4860:a005::68'`. Value may be `undefined` if
327
- * the socket is destroyed (for example, if the client disconnected).
328
- * @since v0.5.10
329
- */
330
- readonly remoteAddress?: string | undefined;
331
- /**
332
- * The string representation of the remote IP family. `'IPv4'` or `'IPv6'`. Value may be `undefined` if
333
- * the socket is destroyed (for example, if the client disconnected).
334
- * @since v0.11.14
335
- */
336
- readonly remoteFamily?: string | undefined;
337
- /**
338
- * The numeric representation of the remote port. For example, `80` or `21`. Value may be `undefined` if
339
- * the socket is destroyed (for example, if the client disconnected).
340
- * @since v0.5.10
341
- */
342
- readonly remotePort?: number | undefined;
343
- /**
344
- * The socket timeout in milliseconds as set by `socket.setTimeout()`.
345
- * It is `undefined` if a timeout has not been set.
346
- * @since v10.7.0
347
- */
348
- readonly timeout?: number | undefined;
349
- /**
350
- * Half-closes the socket. i.e., it sends a FIN packet. It is possible the
351
- * server will still send some data.
352
- *
353
- * See `writable.end()` for further details.
354
- * @since v0.1.90
355
- * @param [encoding='utf8'] Only used when data is `string`.
356
- * @param callback Optional callback for when the socket is finished.
357
- * @return The socket itself.
358
- */
359
- end(callback?: () => void): this;
360
- end(buffer: Uint8Array | string, callback?: () => void): this;
361
- end(str: Uint8Array | string, encoding?: BufferEncoding, callback?: () => void): this;
362
- /**
363
- * events.EventEmitter
364
- * 1. close
365
- * 2. connect
366
- * 3. connectionAttempt
367
- * 4. connectionAttemptFailed
368
- * 5. connectionAttemptTimeout
369
- * 6. data
370
- * 7. drain
371
- * 8. end
372
- * 9. error
373
- * 10. lookup
374
- * 11. ready
375
- * 12. timeout
376
- */
377
- addListener(event: string, listener: (...args: any[]) => void): this;
378
- addListener(event: "close", listener: (hadError: boolean) => void): this;
379
- addListener(event: "connect", listener: () => void): this;
380
- addListener(event: "connectionAttempt", listener: (ip: string, port: number, family: number) => void): this;
381
- addListener(
382
- event: "connectionAttemptFailed",
383
- listener: (ip: string, port: number, family: number) => void,
384
- ): this;
385
- addListener(
386
- event: "connectionAttemptTimeout",
387
- listener: (ip: string, port: number, family: number) => void,
388
- ): this;
389
- addListener(event: "data", listener: (data: Buffer) => void): this;
390
- addListener(event: "drain", listener: () => void): this;
391
- addListener(event: "end", listener: () => void): this;
392
- addListener(event: "error", listener: (err: Error) => void): this;
393
- addListener(
394
- event: "lookup",
395
- listener: (err: Error, address: string, family: string | number, host: string) => void,
396
- ): this;
397
- addListener(event: "ready", listener: () => void): this;
398
- addListener(event: "timeout", listener: () => void): this;
399
- emit(event: string | symbol, ...args: any[]): boolean;
400
- emit(event: "close", hadError: boolean): boolean;
401
- emit(event: "connect"): boolean;
402
- emit(event: "connectionAttempt", ip: string, port: number, family: number): boolean;
403
- emit(event: "connectionAttemptFailed", ip: string, port: number, family: number): boolean;
404
- emit(event: "connectionAttemptTimeout", ip: string, port: number, family: number): boolean;
405
- emit(event: "data", data: Buffer): boolean;
406
- emit(event: "drain"): boolean;
407
- emit(event: "end"): boolean;
408
- emit(event: "error", err: Error): boolean;
409
- emit(event: "lookup", err: Error, address: string, family: string | number, host: string): boolean;
410
- emit(event: "ready"): boolean;
411
- emit(event: "timeout"): boolean;
412
- on(event: string, listener: (...args: any[]) => void): this;
413
- on(event: "close", listener: (hadError: boolean) => void): this;
414
- on(event: "connect", listener: () => void): this;
415
- on(event: "connectionAttempt", listener: (ip: string, port: number, family: number) => void): this;
416
- on(event: "connectionAttemptFailed", listener: (ip: string, port: number, family: number) => void): this;
417
- on(event: "connectionAttemptTimeout", listener: (ip: string, port: number, family: number) => void): this;
418
- on(event: "data", listener: (data: Buffer) => void): this;
419
- on(event: "drain", listener: () => void): this;
420
- on(event: "end", listener: () => void): this;
421
- on(event: "error", listener: (err: Error) => void): this;
422
- on(
423
- event: "lookup",
424
- listener: (err: Error, address: string, family: string | number, host: string) => void,
425
- ): this;
426
- on(event: "ready", listener: () => void): this;
427
- on(event: "timeout", listener: () => void): this;
428
- once(event: string, listener: (...args: any[]) => void): this;
429
- once(event: "close", listener: (hadError: boolean) => void): this;
430
- once(event: "connectionAttempt", listener: (ip: string, port: number, family: number) => void): this;
431
- once(event: "connectionAttemptFailed", listener: (ip: string, port: number, family: number) => void): this;
432
- once(event: "connectionAttemptTimeout", listener: (ip: string, port: number, family: number) => void): this;
433
- once(event: "connect", listener: () => void): this;
434
- once(event: "data", listener: (data: Buffer) => void): this;
435
- once(event: "drain", listener: () => void): this;
436
- once(event: "end", listener: () => void): this;
437
- once(event: "error", listener: (err: Error) => void): this;
438
- once(
439
- event: "lookup",
440
- listener: (err: Error, address: string, family: string | number, host: string) => void,
441
- ): this;
442
- once(event: "ready", listener: () => void): this;
443
- once(event: "timeout", listener: () => void): this;
444
- prependListener(event: string, listener: (...args: any[]) => void): this;
445
- prependListener(event: "close", listener: (hadError: boolean) => void): this;
446
- prependListener(event: "connect", listener: () => void): this;
447
- prependListener(event: "connectionAttempt", listener: (ip: string, port: number, family: number) => void): this;
448
- prependListener(
449
- event: "connectionAttemptFailed",
450
- listener: (ip: string, port: number, family: number) => void,
451
- ): this;
452
- prependListener(
453
- event: "connectionAttemptTimeout",
454
- listener: (ip: string, port: number, family: number) => void,
455
- ): this;
456
- prependListener(event: "data", listener: (data: Buffer) => void): this;
457
- prependListener(event: "drain", listener: () => void): this;
458
- prependListener(event: "end", listener: () => void): this;
459
- prependListener(event: "error", listener: (err: Error) => void): this;
460
- prependListener(
461
- event: "lookup",
462
- listener: (err: Error, address: string, family: string | number, host: string) => void,
463
- ): this;
464
- prependListener(event: "ready", listener: () => void): this;
465
- prependListener(event: "timeout", listener: () => void): this;
466
- prependOnceListener(event: string, listener: (...args: any[]) => void): this;
467
- prependOnceListener(event: "close", listener: (hadError: boolean) => void): this;
468
- prependOnceListener(event: "connect", listener: () => void): this;
469
- prependOnceListener(
470
- event: "connectionAttempt",
471
- listener: (ip: string, port: number, family: number) => void,
472
- ): this;
473
- prependOnceListener(
474
- event: "connectionAttemptFailed",
475
- listener: (ip: string, port: number, family: number) => void,
476
- ): this;
477
- prependOnceListener(
478
- event: "connectionAttemptTimeout",
479
- listener: (ip: string, port: number, family: number) => void,
480
- ): this;
481
- prependOnceListener(event: "data", listener: (data: Buffer) => void): this;
482
- prependOnceListener(event: "drain", listener: () => void): this;
483
- prependOnceListener(event: "end", listener: () => void): this;
484
- prependOnceListener(event: "error", listener: (err: Error) => void): this;
485
- prependOnceListener(
486
- event: "lookup",
487
- listener: (err: Error, address: string, family: string | number, host: string) => void,
488
- ): this;
489
- prependOnceListener(event: "ready", listener: () => void): this;
490
- prependOnceListener(event: "timeout", listener: () => void): this;
491
- }
492
- interface ListenOptions extends Abortable {
493
- port?: number | undefined;
494
- host?: string | undefined;
495
- backlog?: number | undefined;
496
- path?: string | undefined;
497
- exclusive?: boolean | undefined;
498
- readableAll?: boolean | undefined;
499
- writableAll?: boolean | undefined;
500
- /**
501
- * @default false
502
- */
503
- ipv6Only?: boolean | undefined;
504
- }
505
- interface ServerOpts {
506
- /**
507
- * Indicates whether half-opened TCP connections are allowed.
508
- * @default false
509
- */
510
- allowHalfOpen?: boolean | undefined;
511
- /**
512
- * Indicates whether the socket should be paused on incoming connections.
513
- * @default false
514
- */
515
- pauseOnConnect?: boolean | undefined;
516
- /**
517
- * If set to `true`, it disables the use of Nagle's algorithm immediately after a new incoming connection is received.
518
- * @default false
519
- * @since v16.5.0
520
- */
521
- noDelay?: boolean | undefined;
522
- /**
523
- * If set to `true`, it enables keep-alive functionality on the socket immediately after a new incoming connection is received,
524
- * similarly on what is done in `socket.setKeepAlive([enable][, initialDelay])`.
525
- * @default false
526
- * @since v16.5.0
527
- */
528
- keepAlive?: boolean | undefined;
529
- /**
530
- * If set to a positive number, it sets the initial delay before the first keepalive probe is sent on an idle socket.
531
- * @default 0
532
- * @since v16.5.0
533
- */
534
- keepAliveInitialDelay?: number | undefined;
535
- }
536
- interface DropArgument {
537
- localAddress?: string;
538
- localPort?: number;
539
- localFamily?: string;
540
- remoteAddress?: string;
541
- remotePort?: number;
542
- remoteFamily?: string;
543
- }
544
- /**
545
- * This class is used to create a TCP or `IPC` server.
546
- * @since v0.1.90
547
- */
548
- class Server extends EventEmitter {
549
- constructor(connectionListener?: (socket: Socket) => void);
550
- constructor(options?: ServerOpts, connectionListener?: (socket: Socket) => void);
551
- /**
552
- * Start a server listening for connections. A `net.Server` can be a TCP or
553
- * an `IPC` server depending on what it listens to.
554
- *
555
- * Possible signatures:
556
- *
557
- * * `server.listen(handle[, backlog][, callback])`
558
- * * `server.listen(options[, callback])`
559
- * * `server.listen(path[, backlog][, callback])` for `IPC` servers
560
- * * `server.listen([port[, host[, backlog]]][, callback])` for TCP servers
561
- *
562
- * 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'`
563
- * event.
564
- *
565
- * All `listen()` methods can take a `backlog` parameter to specify the maximum
566
- * length of the queue of pending connections. The actual length will be determined
567
- * 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).
568
- *
569
- * All {@link Socket} are set to `SO_REUSEADDR` (see [`socket(7)`](https://man7.org/linux/man-pages/man7/socket.7.html) for
570
- * details).
571
- *
572
- * The `server.listen()` method can be called again if and only if there was an
573
- * error during the first `server.listen()` call or `server.close()` has been
574
- * called. Otherwise, an `ERR_SERVER_ALREADY_LISTEN` error will be thrown.
575
- *
576
- * One of the most common errors raised when listening is `EADDRINUSE`.
577
- * This happens when another server is already listening on the requested`port`/`path`/`handle`. One way to handle this would be to retry
578
- * after a certain amount of time:
579
- *
580
- * ```js
581
- * server.on('error', (e) => {
582
- * if (e.code === 'EADDRINUSE') {
583
- * console.error('Address in use, retrying...');
584
- * setTimeout(() => {
585
- * server.close();
586
- * server.listen(PORT, HOST);
587
- * }, 1000);
588
- * }
589
- * });
590
- * ```
591
- */
592
- listen(port?: number, hostname?: string, backlog?: number, listeningListener?: () => void): this;
593
- listen(port?: number, hostname?: string, listeningListener?: () => void): this;
594
- listen(port?: number, backlog?: number, listeningListener?: () => void): this;
595
- listen(port?: number, listeningListener?: () => void): this;
596
- listen(path: string, backlog?: number, listeningListener?: () => void): this;
597
- listen(path: string, listeningListener?: () => void): this;
598
- listen(options: ListenOptions, listeningListener?: () => void): this;
599
- listen(handle: any, backlog?: number, listeningListener?: () => void): this;
600
- listen(handle: any, listeningListener?: () => void): this;
601
- /**
602
- * Stops the server from accepting new connections and keeps existing
603
- * connections. This function is asynchronous, the server is finally closed
604
- * when all connections are ended and the server emits a `'close'` event.
605
- * The optional `callback` will be called once the `'close'` event occurs. Unlike
606
- * that event, it will be called with an `Error` as its only argument if the server
607
- * was not open when it was closed.
608
- * @since v0.1.90
609
- * @param callback Called when the server is closed.
610
- */
611
- close(callback?: (err?: Error) => void): this;
612
- /**
613
- * Returns the bound `address`, the address `family` name, and `port` of the server
614
- * as reported by the operating system if listening on an IP socket
615
- * (useful to find which port was assigned when getting an OS-assigned address):`{ port: 12346, family: 'IPv4', address: '127.0.0.1' }`.
616
- *
617
- * For a server listening on a pipe or Unix domain socket, the name is returned
618
- * as a string.
619
- *
620
- * ```js
621
- * const server = net.createServer((socket) => {
622
- * socket.end('goodbye\n');
623
- * }).on('error', (err) => {
624
- * // Handle errors here.
625
- * throw err;
626
- * });
627
- *
628
- * // Grab an arbitrary unused port.
629
- * server.listen(() => {
630
- * console.log('opened server on', server.address());
631
- * });
632
- * ```
633
- *
634
- * `server.address()` returns `null` before the `'listening'` event has been
635
- * emitted or after calling `server.close()`.
636
- * @since v0.1.90
637
- */
638
- address(): AddressInfo | string | null;
639
- /**
640
- * Asynchronously get the number of concurrent connections on the server. Works
641
- * when sockets were sent to forks.
642
- *
643
- * Callback should take two arguments `err` and `count`.
644
- * @since v0.9.7
645
- */
646
- getConnections(cb: (error: Error | null, count: number) => void): void;
647
- /**
648
- * 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).
649
- * If the server is `ref`ed calling `ref()` again will have no effect.
650
- * @since v0.9.1
651
- */
652
- ref(): this;
653
- /**
654
- * Calling `unref()` on a server will allow the program to exit if this is the only
655
- * active server in the event system. If the server is already `unref`ed calling`unref()` again will have no effect.
656
- * @since v0.9.1
657
- */
658
- unref(): this;
659
- /**
660
- * Set this property to reject connections when the server's connection count gets
661
- * high.
662
- *
663
- * It is not recommended to use this option once a socket has been sent to a child
664
- * with `child_process.fork()`.
665
- * @since v0.2.0
666
- */
667
- maxConnections: number;
668
- connections: number;
669
- /**
670
- * Indicates whether or not the server is listening for connections.
671
- * @since v5.7.0
672
- */
673
- readonly listening: boolean;
674
- /**
675
- * events.EventEmitter
676
- * 1. close
677
- * 2. connection
678
- * 3. error
679
- * 4. listening
680
- * 5. drop
681
- */
682
- addListener(event: string, listener: (...args: any[]) => void): this;
683
- addListener(event: "close", listener: () => void): this;
684
- addListener(event: "connection", listener: (socket: Socket) => void): this;
685
- addListener(event: "error", listener: (err: Error) => void): this;
686
- addListener(event: "listening", listener: () => void): this;
687
- addListener(event: "drop", listener: (data?: DropArgument) => void): this;
688
- emit(event: string | symbol, ...args: any[]): boolean;
689
- emit(event: "close"): boolean;
690
- emit(event: "connection", socket: Socket): boolean;
691
- emit(event: "error", err: Error): boolean;
692
- emit(event: "listening"): boolean;
693
- emit(event: "drop", data?: DropArgument): boolean;
694
- on(event: string, listener: (...args: any[]) => void): this;
695
- on(event: "close", listener: () => void): this;
696
- on(event: "connection", listener: (socket: Socket) => void): this;
697
- on(event: "error", listener: (err: Error) => void): this;
698
- on(event: "listening", listener: () => void): this;
699
- on(event: "drop", listener: (data?: DropArgument) => void): this;
700
- once(event: string, listener: (...args: any[]) => void): this;
701
- once(event: "close", listener: () => void): this;
702
- once(event: "connection", listener: (socket: Socket) => void): this;
703
- once(event: "error", listener: (err: Error) => void): this;
704
- once(event: "listening", listener: () => void): this;
705
- once(event: "drop", listener: (data?: DropArgument) => void): this;
706
- prependListener(event: string, listener: (...args: any[]) => void): this;
707
- prependListener(event: "close", listener: () => void): this;
708
- prependListener(event: "connection", listener: (socket: Socket) => void): this;
709
- prependListener(event: "error", listener: (err: Error) => void): this;
710
- prependListener(event: "listening", listener: () => void): this;
711
- prependListener(event: "drop", listener: (data?: DropArgument) => void): this;
712
- prependOnceListener(event: string, listener: (...args: any[]) => void): this;
713
- prependOnceListener(event: "close", listener: () => void): this;
714
- prependOnceListener(event: "connection", listener: (socket: Socket) => void): this;
715
- prependOnceListener(event: "error", listener: (err: Error) => void): this;
716
- prependOnceListener(event: "listening", listener: () => void): this;
717
- prependOnceListener(event: "drop", listener: (data?: DropArgument) => void): this;
718
- /**
719
- * Calls {@link Server.close()} and returns a promise that fulfills when the server has closed.
720
- * @since v20.5.0
721
- */
722
- [Symbol.asyncDispose](): Promise<void>;
723
- }
724
- type IPVersion = "ipv4" | "ipv6";
725
- /**
726
- * The `BlockList` object can be used with some network APIs to specify rules for
727
- * disabling inbound or outbound access to specific IP addresses, IP ranges, or
728
- * IP subnets.
729
- * @since v15.0.0, v14.18.0
730
- */
731
- class BlockList {
732
- /**
733
- * Adds a rule to block the given IP address.
734
- * @since v15.0.0, v14.18.0
735
- * @param address An IPv4 or IPv6 address.
736
- * @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`.
737
- */
738
- addAddress(address: string, type?: IPVersion): void;
739
- addAddress(address: SocketAddress): void;
740
- /**
741
- * Adds a rule to block a range of IP addresses from `start` (inclusive) to`end` (inclusive).
742
- * @since v15.0.0, v14.18.0
743
- * @param start The starting IPv4 or IPv6 address in the range.
744
- * @param end The ending IPv4 or IPv6 address in the range.
745
- * @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`.
746
- */
747
- addRange(start: string, end: string, type?: IPVersion): void;
748
- addRange(start: SocketAddress, end: SocketAddress): void;
749
- /**
750
- * Adds a rule to block a range of IP addresses specified as a subnet mask.
751
- * @since v15.0.0, v14.18.0
752
- * @param net The network IPv4 or IPv6 address.
753
- * @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`.
754
- * @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`.
755
- */
756
- addSubnet(net: SocketAddress, prefix: number): void;
757
- addSubnet(net: string, prefix: number, type?: IPVersion): void;
758
- /**
759
- * Returns `true` if the given IP address matches any of the rules added to the`BlockList`.
760
- *
761
- * ```js
762
- * const blockList = new net.BlockList();
763
- * blockList.addAddress('123.123.123.123');
764
- * blockList.addRange('10.0.0.1', '10.0.0.10');
765
- * blockList.addSubnet('8592:757c:efae:4e45::', 64, 'ipv6');
766
- *
767
- * console.log(blockList.check('123.123.123.123')); // Prints: true
768
- * console.log(blockList.check('10.0.0.3')); // Prints: true
769
- * console.log(blockList.check('222.111.111.222')); // Prints: false
770
- *
771
- * // IPv6 notation for IPv4 addresses works:
772
- * console.log(blockList.check('::ffff:7b7b:7b7b', 'ipv6')); // Prints: true
773
- * console.log(blockList.check('::ffff:123.123.123.123', 'ipv6')); // Prints: true
774
- * ```
775
- * @since v15.0.0, v14.18.0
776
- * @param address The IP address to check
777
- * @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`.
778
- */
779
- check(address: SocketAddress): boolean;
780
- check(address: string, type?: IPVersion): boolean;
781
- /**
782
- * The list of rules added to the blocklist.
783
- * @since v15.0.0, v14.18.0
784
- */
785
- rules: readonly string[];
786
- }
787
- interface TcpNetConnectOpts extends TcpSocketConnectOpts, SocketConstructorOpts {
788
- timeout?: number | undefined;
789
- }
790
- interface IpcNetConnectOpts extends IpcSocketConnectOpts, SocketConstructorOpts {
791
- timeout?: number | undefined;
792
- }
793
- type NetConnectOpts = TcpNetConnectOpts | IpcNetConnectOpts;
794
- /**
795
- * Creates a new TCP or `IPC` server.
796
- *
797
- * If `allowHalfOpen` is set to `true`, when the other end of the socket
798
- * signals the end of transmission, the server will only send back the end of
799
- * transmission when `socket.end()` is explicitly called. For example, in the
800
- * context of TCP, when a FIN packed is received, a FIN packed is sent
801
- * back only when `socket.end()` is explicitly called. Until then the
802
- * 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.
803
- *
804
- * If `pauseOnConnect` is set to `true`, then the socket associated with each
805
- * incoming connection will be paused, and no data will be read from its handle.
806
- * This allows connections to be passed between processes without any data being
807
- * read by the original process. To begin reading data from a paused socket, call `socket.resume()`.
808
- *
809
- * The server can be a TCP server or an `IPC` server, depending on what it `listen()` to.
810
- *
811
- * Here is an example of a TCP echo server which listens for connections
812
- * on port 8124:
813
- *
814
- * ```js
815
- * const net = require('node:net');
816
- * const server = net.createServer((c) => {
817
- * // 'connection' listener.
818
- * console.log('client connected');
819
- * c.on('end', () => {
820
- * console.log('client disconnected');
821
- * });
822
- * c.write('hello\r\n');
823
- * c.pipe(c);
824
- * });
825
- * server.on('error', (err) => {
826
- * throw err;
827
- * });
828
- * server.listen(8124, () => {
829
- * console.log('server bound');
830
- * });
831
- * ```
832
- *
833
- * Test this by using `telnet`:
834
- *
835
- * ```bash
836
- * telnet localhost 8124
837
- * ```
838
- *
839
- * To listen on the socket `/tmp/echo.sock`:
840
- *
841
- * ```js
842
- * server.listen('/tmp/echo.sock', () => {
843
- * console.log('server bound');
844
- * });
845
- * ```
846
- *
847
- * Use `nc` to connect to a Unix domain socket server:
848
- *
849
- * ```bash
850
- * nc -U /tmp/echo.sock
851
- * ```
852
- * @since v0.5.0
853
- * @param connectionListener Automatically set as a listener for the {@link 'connection'} event.
854
- */
855
- function createServer(connectionListener?: (socket: Socket) => void): Server;
856
- function createServer(options?: ServerOpts, connectionListener?: (socket: Socket) => void): Server;
857
- /**
858
- * Aliases to {@link createConnection}.
859
- *
860
- * Possible signatures:
861
- *
862
- * * {@link connect}
863
- * * {@link connect} for `IPC` connections.
864
- * * {@link connect} for TCP connections.
865
- */
866
- function connect(options: NetConnectOpts, connectionListener?: () => void): Socket;
867
- function connect(port: number, host?: string, connectionListener?: () => void): Socket;
868
- function connect(path: string, connectionListener?: () => void): Socket;
869
- /**
870
- * A factory function, which creates a new {@link Socket},
871
- * immediately initiates connection with `socket.connect()`,
872
- * then returns the `net.Socket` that starts the connection.
873
- *
874
- * When the connection is established, a `'connect'` event will be emitted
875
- * on the returned socket. The last parameter `connectListener`, if supplied,
876
- * will be added as a listener for the `'connect'` event **once**.
877
- *
878
- * Possible signatures:
879
- *
880
- * * {@link createConnection}
881
- * * {@link createConnection} for `IPC` connections.
882
- * * {@link createConnection} for TCP connections.
883
- *
884
- * The {@link connect} function is an alias to this function.
885
- */
886
- function createConnection(options: NetConnectOpts, connectionListener?: () => void): Socket;
887
- function createConnection(port: number, host?: string, connectionListener?: () => void): Socket;
888
- function createConnection(path: string, connectionListener?: () => void): Socket;
889
- /**
890
- * Gets the current default value of the `autoSelectFamily` option of `socket.connect(options)`.
891
- * The initial default value is `true`, unless the command line option`--no-network-family-autoselection` is provided.
892
- * @since v19.4.0
893
- */
894
- function getDefaultAutoSelectFamily(): boolean;
895
- /**
896
- * Sets the default value of the `autoSelectFamily` option of `socket.connect(options)`.
897
- * @since v19.4.0
898
- */
899
- function setDefaultAutoSelectFamily(value: boolean): void;
900
- /**
901
- * Gets the current default value of the `autoSelectFamilyAttemptTimeout` option of `socket.connect(options)`.
902
- * The initial default value is `250` or the value specified via the command line option `--network-family-autoselection-attempt-timeout`.
903
- * @returns The current default value of the `autoSelectFamilyAttemptTimeout` option.
904
- * @since v19.8.0, v18.8.0
905
- */
906
- function getDefaultAutoSelectFamilyAttemptTimeout(): number;
907
- /**
908
- * Sets the default value of the `autoSelectFamilyAttemptTimeout` option of `socket.connect(options)`.
909
- * @param value The new default value, which must be a positive number. If the number is less than `10`, the value `10` is used instead. The initial default value is `250` or the value specified via the command line
910
- * option `--network-family-autoselection-attempt-timeout`.
911
- * @since v19.8.0, v18.8.0
912
- */
913
- function setDefaultAutoSelectFamilyAttemptTimeout(value: number): void;
914
- /**
915
- * Returns `6` if `input` is an IPv6 address. Returns `4` if `input` is an IPv4
916
- * address in [dot-decimal notation](https://en.wikipedia.org/wiki/Dot-decimal_notation) with no leading zeroes. Otherwise, returns`0`.
917
- *
918
- * ```js
919
- * net.isIP('::1'); // returns 6
920
- * net.isIP('127.0.0.1'); // returns 4
921
- * net.isIP('127.000.000.001'); // returns 0
922
- * net.isIP('127.0.0.1/24'); // returns 0
923
- * net.isIP('fhqwhgads'); // returns 0
924
- * ```
925
- * @since v0.3.0
926
- */
927
- function isIP(input: string): number;
928
- /**
929
- * Returns `true` if `input` is an IPv4 address in [dot-decimal notation](https://en.wikipedia.org/wiki/Dot-decimal_notation) with no
930
- * leading zeroes. Otherwise, returns `false`.
931
- *
932
- * ```js
933
- * net.isIPv4('127.0.0.1'); // returns true
934
- * net.isIPv4('127.000.000.001'); // returns false
935
- * net.isIPv4('127.0.0.1/24'); // returns false
936
- * net.isIPv4('fhqwhgads'); // returns false
937
- * ```
938
- * @since v0.3.0
939
- */
940
- function isIPv4(input: string): boolean;
941
- /**
942
- * Returns `true` if `input` is an IPv6 address. Otherwise, returns `false`.
943
- *
944
- * ```js
945
- * net.isIPv6('::1'); // returns true
946
- * net.isIPv6('fhqwhgads'); // returns false
947
- * ```
948
- * @since v0.3.0
949
- */
950
- function isIPv6(input: string): boolean;
951
- interface SocketAddressInitOptions {
952
- /**
953
- * The network address as either an IPv4 or IPv6 string.
954
- * @default 127.0.0.1
955
- */
956
- address?: string | undefined;
957
- /**
958
- * @default `'ipv4'`
959
- */
960
- family?: IPVersion | undefined;
961
- /**
962
- * An IPv6 flow-label used only if `family` is `'ipv6'`.
963
- * @default 0
964
- */
965
- flowlabel?: number | undefined;
966
- /**
967
- * An IP port.
968
- * @default 0
969
- */
970
- port?: number | undefined;
971
- }
972
- /**
973
- * @since v15.14.0, v14.18.0
974
- */
975
- class SocketAddress {
976
- constructor(options: SocketAddressInitOptions);
977
- /**
978
- * Either \`'ipv4'\` or \`'ipv6'\`.
979
- * @since v15.14.0, v14.18.0
980
- */
981
- readonly address: string;
982
- /**
983
- * Either \`'ipv4'\` or \`'ipv6'\`.
984
- * @since v15.14.0, v14.18.0
985
- */
986
- readonly family: IPVersion;
987
- /**
988
- * @since v15.14.0, v14.18.0
989
- */
990
- readonly port: number;
991
- /**
992
- * @since v15.14.0, v14.18.0
993
- */
994
- readonly flowlabel: number;
995
- }
996
- }
997
- declare module "node:net" {
998
- export * from "net";
999
- }