1 | # port-numbers
|
2 | [![](https://img.shields.io/npm/v/port-numbers.svg?style=flat)](https://www.npmjs.org/package/port-numbers) [![](https://img.shields.io/npm/dm/port-numbers.svg)](https://www.npmjs.org/package/port-numbers)
|
3 | > 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 | ### Installation
|
6 | ```
|
7 | npm i port-numbers
|
8 | ```
|
9 | ### Example
|
10 | ```js
|
11 | const portNumbers = require('port-numbers');
|
12 |
|
13 | portNumbers.getService(6379);
|
14 | // { name: 'redis', description: 'An advanced key-value cache and store' }
|
15 | portNumbers.getService(26257);
|
16 | // { name: 'cockroach', description: 'CockroachDB' }
|
17 | portNumbers.getService(123, 'udp');
|
18 | // { name: 'ntp', description: 'Network Time Protocol' }
|
19 |
|
20 | portNumbers.getPort('redis');
|
21 | // { port: 6379, protocol: 'tcp', description: 'An advanced key-value cache and store' }
|
22 | portNumbers.getPort('cockroach');
|
23 | // { port: 26257, protocol: 'tcp', description: 'CockroachDB' }
|
24 | portNumbers.getPort('ntp', 'udp');
|
25 | // { port: 123, protocol: 'udp', description: 'Network Time Protocol' }
|
26 | ```
|
27 |
|
28 | ### APIs
|
29 | #### portNumbers.getService(port[, protocol])
|
30 | - `port` *Number* : the port to lookup. Required.
|
31 | - `protocol` *String* : the protocol. Default: `tcp`.
|
32 |
|
33 | #### portNumbers.getPort(service[, protocol])
|
34 | - `service` *String* : the service to lookup. Required.
|
35 | - `protocol` *String* : the protocol. Default: `tcp`.
|
36 |
|
37 | © [silverwind](https://github.com/silverwind), distributed under BSD licence
|