question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add method to get either IPv6 or IPv4

See original GitHub issue

Currently, in the browser version if v6 function is called and the API request returns a v4 version, then an error is made and we can’t get the IP.

It’d be good if there’s a single function to return IPV6/IPV4, if v6 is available :

console.log(await publicIp.get());
//=> '46.5.21.123' or v6 if available (preferred)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
sindresorhuscommented, May 24, 2020

It’d be good if there’s a single function to return IPV6/IPV4, if v6 is available :

You can do this yourself with https://github.com/sindresorhus/p-any and eventually Promise.any

1reaction
subins2000commented, May 26, 2020

How about simply get ? That’d go good with the module name :

const publicIp = require('public-ip');
(async () => {
	console.log(await publicIp.get());
	//=> IPv6, if not IPv4
})();
Read more comments on GitHub >

github_iconTop Results From Across the Web

Example: Accepting connections from both IPv6 and IPv4 clients
This example program demonstrates how to create a server/client model that accepts requests from both IPv4 (those socket applications that use the AF_INET ......
Read more >
ipaddress — IPv4/IPv6 manipulation library — Python 3.11.1 ...
Return an IPv4Address or IPv6Address object depending on the IP address passed as argument. Either IPv4 or IPv6 addresses may be supplied; integers...
Read more >
Add possibility to specify IPv4 or IPv6? · Issue #1691 - GitHub
I noticed that request by default uses IPv6 if a host is capable of it. However, requests seems to lack the ability to...
Read more >
Force requests to use IPv4 / IPv6 - python - Stack Overflow
I've found a minimalistic solution to force urrlib3 to use either ipv4 or ipv6. This method is used by urrlib3 for creating new...
Read more >
How to tell if you are on IPv4 or IPv6 - Level Up Coding
This can actually change per device, you may have IPv6 enabled on your internet connection, however, if your Local Area Network (LAN) isn't...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found