Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
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!
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
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.