UNPKG

1.41 kBMarkdownView Raw
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```
7npm i port-numbers
8```
9```js
10const {getService, getPort} = require('port-numbers');
11
12getService(6379);
13// { name: 'redis', description: 'An advanced key-value cache and store' }
14getService(26257);
15// { name: 'cockroach', description: 'CockroachDB' }
16getService(123, 'udp');
17// { name: 'ntp', description: 'Network Time Protocol' }
18
19getPort('redis');
20// { port: 6379, protocol: 'tcp', description: 'An advanced key-value cache and store' }
21getPort('cockroach');
22// { port: 26257, protocol: 'tcp', description: 'CockroachDB' }
23getPort('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