@egen-civitas/egen 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +0 -0
- package/dist/utils/port.d.ts +5 -0
- package/dist/utils/port.d.ts.map +1 -1
- package/dist/utils/port.js +11 -2
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
File without changes
|
package/dist/utils/port.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Checks if a port is available for use by attempting to bind to it.
|
|
3
3
|
* Checks both IPv4 (0.0.0.0) and IPv6 (::) to ensure the port is truly available.
|
|
4
|
+
* If IPv6 itself isn't supported in the current environment (EAFNOSUPPORT /
|
|
5
|
+
* EADDRNOTAVAIL — common in minimal containers and some CI runners), the IPv6
|
|
6
|
+
* check is skipped rather than treated as "port unavailable": otherwise this
|
|
7
|
+
* function would always report every port as taken, and egen would never be
|
|
8
|
+
* able to start at all in such an environment.
|
|
4
9
|
* @param port The port number to check
|
|
5
10
|
* @returns A promise that resolves to true if the port is available, false otherwise
|
|
6
11
|
*/
|
package/dist/utils/port.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"port.d.ts","sourceRoot":"","sources":["../../src/utils/port.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"port.d.ts","sourceRoot":"","sources":["../../src/utils/port.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CA6B9D;AAED;;;;;GAKG;AACH,wBAAsB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAQzE"}
|
package/dist/utils/port.js
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import { createServer } from "node:net";
|
|
2
2
|
const MAX_PORT = 65535;
|
|
3
|
+
const IPV6_UNSUPPORTED_CODES = new Set([
|
|
4
|
+
'EAFNOSUPPORT',
|
|
5
|
+
'EADDRNOTAVAIL'
|
|
6
|
+
]);
|
|
3
7
|
/**
|
|
4
8
|
* Checks if a port is available for use by attempting to bind to it.
|
|
5
9
|
* Checks both IPv4 (0.0.0.0) and IPv6 (::) to ensure the port is truly available.
|
|
10
|
+
* If IPv6 itself isn't supported in the current environment (EAFNOSUPPORT /
|
|
11
|
+
* EADDRNOTAVAIL — common in minimal containers and some CI runners), the IPv6
|
|
12
|
+
* check is skipped rather than treated as "port unavailable": otherwise this
|
|
13
|
+
* function would always report every port as taken, and egen would never be
|
|
14
|
+
* able to start at all in such an environment.
|
|
6
15
|
* @param port The port number to check
|
|
7
16
|
* @returns A promise that resolves to true if the port is available, false otherwise
|
|
8
17
|
*/ export function isPortAvailable(port) {
|
|
@@ -15,8 +24,8 @@ const MAX_PORT = 65535;
|
|
|
15
24
|
// Port is available on IPv4, now check IPv6
|
|
16
25
|
server.close(()=>{
|
|
17
26
|
const server6 = createServer();
|
|
18
|
-
server6.once('error', ()=>{
|
|
19
|
-
resolve(false);
|
|
27
|
+
server6.once('error', (err)=>{
|
|
28
|
+
resolve(IPV6_UNSUPPORTED_CODES.has(err.code ?? '') ? true : false);
|
|
20
29
|
});
|
|
21
30
|
server6.once('listening', ()=>{
|
|
22
31
|
server6.close(()=>{
|