port-numbers 6.0.1 → 7.0.0
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/README.md +3 -2
- package/index.js +7 -7
- package/package.json +18 -31
- package/ports.json +449 -57
- package/services.json +344 -44
- package/LICENSE +0 -22
package/README.md
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# port-numbers
|
|
2
|
-
[](https://www.npmjs.org/package/port-numbers) [](https://www.npmjs.org/package/port-numbers)
|
|
2
|
+
[](https://www.npmjs.org/package/port-numbers) [](https://www.npmjs.org/package/port-numbers) [](https://packagephobia.com/result?p=port-numbers)
|
|
3
|
+
|
|
3
4
|
> Get information on network port numbers and services, based on [IANA's public listing](http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml).
|
|
4
5
|
|
|
5
6
|
### Usage
|
|
@@ -7,7 +8,7 @@
|
|
|
7
8
|
npm i port-numbers
|
|
8
9
|
```
|
|
9
10
|
```js
|
|
10
|
-
|
|
11
|
+
import {getService, getPort} from "port-numbers";
|
|
11
12
|
|
|
12
13
|
getService(6379);
|
|
13
14
|
// { name: 'redis', description: 'An advanced key-value cache and store' }
|
package/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
import {readFileSync} from "node:fs";
|
|
2
2
|
|
|
3
3
|
let ports, services;
|
|
4
4
|
|
|
5
5
|
// port -> service
|
|
6
|
-
|
|
6
|
+
export function getService(port, protocol = "tcp") {
|
|
7
7
|
if (typeof port !== "number") throw new Error("expected a 'number'");
|
|
8
|
-
if (!ports) ports =
|
|
8
|
+
if (!ports) ports = JSON.parse(readFileSync(new URL("ports.json", import.meta.url)));
|
|
9
9
|
return ports[`${port}/${protocol}`] || null;
|
|
10
|
-
}
|
|
10
|
+
}
|
|
11
11
|
|
|
12
12
|
// service -> port
|
|
13
|
-
|
|
13
|
+
export function getPort(service, protocol = "tcp") {
|
|
14
14
|
if (typeof service !== "string") throw new Error("expected a 'string'");
|
|
15
|
-
if (!services) services =
|
|
15
|
+
if (!services) services = JSON.parse(readFileSync(new URL("services.json", import.meta.url)));
|
|
16
16
|
|
|
17
17
|
// services are always lowercase
|
|
18
18
|
const entry = services[service.toLowerCase()];
|
|
@@ -28,4 +28,4 @@ module.exports.getPort = (service, protocol = "tcp") => {
|
|
|
28
28
|
protocol: /\w+$/.exec(port)[0],
|
|
29
29
|
description: entry.description
|
|
30
30
|
};
|
|
31
|
-
}
|
|
31
|
+
}
|
package/package.json
CHANGED
|
@@ -1,42 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "port-numbers",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "Get information on network port numbers and services, based on IANA's public listing",
|
|
5
|
-
"author": "silverwind
|
|
6
|
-
"license": "BSD-2-Clause",
|
|
5
|
+
"author": "silverwind",
|
|
7
6
|
"repository": "silverwind/port-numbers",
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
"license": "BSD-2-Clause",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"sideEffects": false,
|
|
11
10
|
"engines": {
|
|
12
|
-
"node": ">=
|
|
11
|
+
"node": ">=16"
|
|
13
12
|
},
|
|
14
13
|
"files": [
|
|
15
|
-
"index.js",
|
|
16
|
-
"ports.json",
|
|
17
|
-
"services.json"
|
|
18
|
-
],
|
|
19
|
-
"keywords": [
|
|
20
|
-
"port",
|
|
21
|
-
"port-numbers",
|
|
22
|
-
"numbers",
|
|
23
|
-
"tcp",
|
|
24
|
-
"udp",
|
|
25
|
-
"network",
|
|
26
|
-
"networking",
|
|
27
|
-
"iana",
|
|
28
|
-
"well-known"
|
|
14
|
+
"./index.js",
|
|
15
|
+
"./ports.json",
|
|
16
|
+
"./services.json"
|
|
29
17
|
],
|
|
30
18
|
"devDependencies": {
|
|
31
|
-
"
|
|
32
|
-
"eslint": "
|
|
33
|
-
"eslint-config-silverwind": "
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"verbose": false
|
|
19
|
+
"d3-dsv": "3.0.1",
|
|
20
|
+
"eslint": "8.40.0",
|
|
21
|
+
"eslint-config-silverwind": "71.0.3",
|
|
22
|
+
"fetch-enhanced": "11.1.1",
|
|
23
|
+
"got": "12.6.0",
|
|
24
|
+
"undici": "5.22.1",
|
|
25
|
+
"updates": "14.1.0",
|
|
26
|
+
"versions": "11.0.0",
|
|
27
|
+
"vitest": "0.31.0"
|
|
41
28
|
}
|
|
42
29
|
}
|