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