Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
The public-ip npm package allows you to get your public IP address (IPv4 or IPv6) from different services. It supports both IPv4 and IPv6, and it can be used in Node.js environments.
Get IPv4 Address
This feature allows you to get your public IPv4 address. The code sample demonstrates how to use the public-ip package to fetch and log the IPv4 address.
const publicIp = require('public-ip');
(async () => {
console.log(await publicIp.v4());
})();
Get IPv6 Address
This feature allows you to get your public IPv6 address. The code sample demonstrates how to use the public-ip package to fetch and log the IPv6 address.
const publicIp = require('public-ip');
(async () => {
console.log(await publicIp.v6());
})();
Get IP Address with Options
This feature allows you to get your public IP address with additional options. The code sample demonstrates how to use the public-ip package to fetch the IPv4 address using only HTTPS services.
const publicIp = require('public-ip');
(async () => {
console.log(await publicIp.v4({ onlyHttps: true }));
})();
The ipify package is another tool to get your public IP address. It is similar to public-ip but focuses on using the ipify service to fetch the IP address. It supports both IPv4 and IPv6.
The external-ip package provides a way to get your public IP address by querying multiple services and returning the first successful response. It offers more flexibility in terms of service selection compared to public-ip.
The public-ip-cli package is a command-line interface for the public-ip package. It allows you to fetch your public IP address directly from the command line, making it convenient for quick checks without writing code.
Get your public IP address - very fast!
In Node.js, it queries the DNS records of OpenDNS which has an entry with your IP address.
In browsers, it uses the excellent icanhaz service through HTTPS.
$ npm install --save public-ip
const publicIp = require('public-ip');
publicIp.v4().then(ip => {
console.log(ip);
//=> '46.5.21.123'
});
publicIp.v6().then(ip => {
console.log(ip);
//=> 'fe80::200:f8ff:fe21:67cf'
});
Returns a Promise
which resolves to your public IPv4 or IPv6 address. Will reject on error or timeout. A .cancel()
method is available on the promise, which can be used to cancel the request.
Type: Object
Type: boolean
Default: false
Use a HTTPS check using the icanhazip.com service instead of the DNS query. This check is much more secure and tamper-proof, but also a lot slower. This option is only available in the Node.js version.
Type: number
Default: 5000
The time in milliseconds until a request is considered timed out.
MIT © Sindre Sorhus
FAQs
Get your public IP address — very fast!
The npm package public-ip receives a total of 127,978 weekly downloads. As such, public-ip popularity was classified as popular.
We found that public-ip demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.