ip-detect-utils-fast
v1.0.0
Published
Fast and easy-to-use IP detection for public (IPv4/IPv6) and local addresses in Node.js.
Maintainers
Readme
ip-detect-fast
Fast and easy-to-use IP detection for Node.js. Quickly detect your public IPv4, public IPv6, and local network IP addresses.
Features
- Detect Public IPv4
- Detect Public IPv6
- List Local IP Addresses
- Zero External Dependencies (Uses Node.js Built-in Fetch and OS Module)
Installation
npm install ip-detect-fastUsage
const { getPublicIPv4, getPublicIPv6, getLocalIP, getAllIPInfo } = require('ip-detect-fast');
(async () => {
// Get public IPv4
try {
const publicIPv4 = await getPublicIPv4();
console.log('Public IPv4:', publicIPv4);
} catch (err) {
console.error(err.message);
}
// Get public IPv6
try {
const publicIPv6 = await getPublicIPv6();
console.log('Public IPv6:', publicIPv6);
} catch (err) {
console.error(err.message);
}
// Get all local IPs
const localIPs = getLocalIPs();
console.log('Local IPs:', localIPs);
// Get everything at once
const allInfo = await getAllIPInfo();
console.log('All IP Info:', allInfo);
})();API
getPublicIPv4()
Returns a Promise<string> with the public IPv4 address.
getPublicIPv6()
Returns a Promise<string> with the public IPv6 address.
getLocalIP()
Returns an object mapping interface names to arrays of local IP address details.
getAllIPInfo()
Returns a Promise<Object> containing publicIPv4, publicIPv6, and local IP details.
License
MIT
