source: trip-planner-front/node_modules/default-gateway/README.md@ 6a3a178

Last change on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.8 KB
Line 
1# default-gateway
2[![](https://img.shields.io/npm/v/default-gateway.svg?style=flat)](https://www.npmjs.org/package/default-gateway) [![](https://img.shields.io/npm/dm/default-gateway.svg)](https://www.npmjs.org/package/default-gateway) [![](https://api.travis-ci.org/silverwind/default-gateway.svg?style=flat)](https://travis-ci.org/silverwind/default-gateway)
3
4> Get the default network gateway, cross-platform.
5
6Obtains the machine's default gateway through `exec` calls to OS routing interfaces. On Linux and Android, the `ip` command must be available (usually provided by the `iproute2` package). On IBM i, the `db2util` command must be available (provided by the `db2util` package).
7
8## Installation
9
10```
11$ npm install default-gateway
12```
13
14## Example
15
16```js
17const defaultGateway = require('default-gateway');
18
19defaultGateway.v4().then(result => {
20 // result = {gateway: '1.2.3.4', interface: 'en1'}
21});
22
23defaultGateway.v6().then(result => {
24 // result = {gateway: '2001:db8::1', interface: 'en2'}
25});
26
27const result = defaultGateway.v4.sync();
28// result = {gateway: '1.2.3.4', interface: 'en1'}
29
30const result = defaultGateway.v6.sync();
31// result = {gateway: '2001:db8::1', interface: 'en2'}
32```
33
34## API
35### defaultGateway.v4()
36### defaultGateway.v6()
37### defaultGateway.v4.sync()
38### defaultGateway.v6.sync()
39
40Returns: `result` *Object*
41 - `gateway`: The IP address of the default gateway.
42 - `interface`: The name of the interface. On Windows, this is the network adapter name.
43
44The `.v{4,6}()` methods return a Promise while the `.v{4,6}.sync()` variants will return the result synchronously.
45
46The `gateway` property will always be defined on success, while `interface` can be `null` if it cannot be determined. All methods reject/throw on unexpected conditions.
47
48## License
49
50© [silverwind](https://github.com/silverwind), distributed under BSD licence
Note: See TracBrowser for help on using the repository browser.