internal-ip
Advanced tools
Comparing version 4.3.0 to 5.0.0
interface v6 { | ||
/** | ||
* @returns The IPv6 address of the internet-facing interface, as determined from the default gateway. When the address cannot be determined for any reason, `null` will be returned. | ||
* | ||
* @example | ||
* | ||
* console.log(await internalIp.v6()); | ||
* //=> 'fe80::1' | ||
*/ | ||
(): Promise<string>; | ||
@returns The IPv6 address of the internet-facing interface, as determined from the default gateway. When the address cannot be determined for any reason, `undefined` will be returned. | ||
@example | ||
``` | ||
import internalIp = require('internal-ip'); | ||
console.log(await internalIp.v6()); | ||
//=> 'fe80::1' | ||
``` | ||
*/ | ||
(): Promise<string | undefined>; | ||
/** | ||
* @returns The IPv6 address of the internet-facing interface, as determined from the default gateway. When the address cannot be determined for any reason, `null` will be returned. | ||
* | ||
* @example | ||
* | ||
* console.log(internalIp.v6.sync()); | ||
* //=> 'fe80::1' | ||
*/ | ||
sync(): string; | ||
@returns The IPv6 address of the internet-facing interface, as determined from the default gateway. When the address cannot be determined for any reason, `undefined` will be returned. | ||
@example | ||
``` | ||
import internalIp = require('internal-ip'); | ||
console.log(internalIp.v6.sync()); | ||
//=> 'fe80::1' | ||
``` | ||
*/ | ||
sync(): string | undefined; | ||
} | ||
@@ -25,20 +31,26 @@ | ||
/** | ||
* @returns The IPv4 address of the internet-facing interface, as determined from the default gateway. When the address cannot be determined for any reason, `null` will be returned. | ||
* | ||
* @example | ||
* | ||
* console.log(await internalIp.v4()) | ||
* //=> '10.0.0.79' | ||
*/ | ||
(): Promise<string>; | ||
@returns The IPv4 address of the internet-facing interface, as determined from the default gateway. When the address cannot be determined for any reason, `undefined` will be returned. | ||
@example | ||
``` | ||
import internalIp = require('internal-ip'); | ||
console.log(await internalIp.v4()) | ||
//=> '10.0.0.79' | ||
``` | ||
*/ | ||
(): Promise<string | undefined>; | ||
/** | ||
* @returns The IPv4 address of the internet-facing interface, as determined from the default gateway. When the address cannot be determined for any reason, `null` will be returned. | ||
* | ||
* @example | ||
* | ||
* console.log(internalIp.v4.sync()) | ||
* //=> '10.0.0.79' | ||
*/ | ||
sync(): string; | ||
@returns The IPv4 address of the internet-facing interface, as determined from the default gateway. When the address cannot be determined for any reason, `undefined` will be returned. | ||
@example | ||
``` | ||
import internalIp = require('internal-ip'); | ||
console.log(internalIp.v4.sync()) | ||
//=> '10.0.0.79' | ||
``` | ||
*/ | ||
sync(): string | undefined; | ||
} | ||
@@ -49,7 +61,4 @@ | ||
v4: v4; | ||
// TODO: Remove this for the next major release | ||
default: typeof internalIp; | ||
}; | ||
export = internalIp; |
17
index.js
@@ -28,6 +28,7 @@ 'use strict'; | ||
function promise(family) { | ||
return defaultGateway[family]().then(result => { | ||
return findIp(result.gateway) || null; | ||
}).catch(() => null); | ||
async function promise(family) { | ||
try { | ||
const result = await defaultGateway[family](); | ||
return findIp(result.gateway); | ||
} catch (_) {} | ||
} | ||
@@ -38,6 +39,4 @@ | ||
const result = defaultGateway[family].sync(); | ||
return findIp(result.gateway) || null; | ||
} catch (error) { | ||
return null; | ||
} | ||
return findIp(result.gateway); | ||
} catch (_) {} | ||
} | ||
@@ -52,3 +51,1 @@ | ||
module.exports = internalIp; | ||
// TODO: Remove this for the next major release | ||
module.exports.default = internalIp; |
{ | ||
"name": "internal-ip", | ||
"version": "4.3.0", | ||
"version": "5.0.0", | ||
"description": "Get your internal IP address", | ||
@@ -13,3 +13,3 @@ "license": "MIT", | ||
"engines": { | ||
"node": ">=6" | ||
"node": ">=8" | ||
}, | ||
@@ -36,10 +36,10 @@ "scripts": { | ||
"dependencies": { | ||
"default-gateway": "^4.2.0", | ||
"ipaddr.js": "^1.9.0" | ||
"default-gateway": "^5.0.4", | ||
"ipaddr.js": "^1.9.1" | ||
}, | ||
"devDependencies": { | ||
"ava": "^1.4.1", | ||
"tsd": "^0.7.2", | ||
"xo": "^0.24.0" | ||
"ava": "^2.4.0", | ||
"tsd": "^0.9.0", | ||
"xo": "^0.25.3" | ||
} | ||
} |
@@ -33,3 +33,3 @@ # internal-ip [![Build Status](https://travis-ci.org/sindresorhus/internal-ip.svg?branch=master)](https://travis-ci.org/sindresorhus/internal-ip) | ||
The module returns the address of the internet-facing interface, as determined from the default gateway. When the address cannot be determined for any reason, `null` will be returned. | ||
The module returns the address of the internet-facing interface, as determined from the default gateway. When the address cannot be determined for any reason, `undefined` will be returned. | ||
@@ -46,4 +46,12 @@ The module relies on operating systems tools. On Linux and Android, the `ip` command must be available, which depending on distribution might not be installed by default. It is usually provided by the `iproute2` package. | ||
## License | ||
--- | ||
MIT © [Sindre Sorhus](https://sindresorhus.com) | ||
<div align="center"> | ||
<b> | ||
<a href="https://tidelift.com/subscription/pkg/npm-internal-ip?utm_source=npm-internal-ip&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a> | ||
</b> | ||
<br> | ||
<sub> | ||
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies. | ||
</sub> | ||
</div> |
6125
56
88
+ Addedcross-spawn@7.0.3(transitive)
+ Addeddefault-gateway@5.0.5(transitive)
+ Addedexeca@3.4.0(transitive)
+ Addedget-stream@5.2.0(transitive)
+ Addedhuman-signals@1.1.1(transitive)
+ Addedis-stream@2.0.1(transitive)
+ Addedmerge-stream@2.0.0(transitive)
+ Addedmimic-fn@2.1.0(transitive)
+ Addednpm-run-path@4.0.1(transitive)
+ Addedonetime@5.1.2(transitive)
+ Addedp-finally@2.0.1(transitive)
+ Addedpath-key@3.1.1(transitive)
+ Addedshebang-command@2.0.0(transitive)
+ Addedshebang-regex@3.0.0(transitive)
+ Addedstrip-final-newline@2.0.0(transitive)
+ Addedwhich@2.0.2(transitive)
- Removedcross-spawn@6.0.5(transitive)
- Removeddefault-gateway@4.2.0(transitive)
- Removedexeca@1.0.0(transitive)
- Removedget-stream@4.1.0(transitive)
- Removedip-regex@2.1.0(transitive)
- Removedis-stream@1.1.0(transitive)
- Removednice-try@1.0.5(transitive)
- Removednpm-run-path@2.0.2(transitive)
- Removedp-finally@1.0.0(transitive)
- Removedpath-key@2.0.1(transitive)
- Removedsemver@5.7.2(transitive)
- Removedshebang-command@1.2.0(transitive)
- Removedshebang-regex@1.0.0(transitive)
- Removedstrip-eof@1.0.0(transitive)
- Removedwhich@1.3.1(transitive)
Updateddefault-gateway@^5.0.4
Updatedipaddr.js@^1.9.1