speedtest icon indicating copy to clipboard operation
speedtest copied to clipboard

Make getIP client side

Open gustavoberman opened this issue 4 years ago • 10 comments

Description

Make getIP client side (js) instead of server side. Or have the possibility to choose which side to use.

Why it should be implemented

Our speedtest is hosted inside a VPN. We use it to test client-to-server tunnel. So every client source IP is a private address. Having the possibility to do it client side will give us the public IP of the client and so being able to know which ISP it is using. Also, our speedtest host don't have access to Internet, just local network, so current getIP is unable to reach ipinfo.io.

Thanks!

gustavoberman avatar Jun 28 '21 13:06 gustavoberman

That's an interesting concept, I'm not sure if ipinfo allows it since it's technically bypassing the API key requirement, I'll have to investigate it and do some tests.

adolfintel avatar Jun 29 '21 09:06 adolfintel

I tried inserting this in index.html and it gets my public source IP:

<script>
function getSourceIP(json) {
  alert("My public IP address is: " + json.ip);
}
</script>
<script src="https://api.ipify.org?format=jsonp&callback=getSourceIP"></script>

But I have no idea how to do the rest

gustavoberman avatar Jun 29 '21 12:06 gustavoberman

If this gets implemented it should definitely be opt-in. Not everyone wants to connect to a third party site.

Perflyst avatar Jul 01 '21 10:07 Perflyst

See my #436 . Does your proxy have a header like "forward for"?

songsammy avatar Oct 01 '21 01:10 songsammy

See my #436 . Does your proxy have a header like "forward for"?

Yes it does. But it returns a private address since I'm connected to the VPN

gustavoberman avatar Oct 01 '21 12:10 gustavoberman

Wait, there's something I didn't get. Do you mean the server is behind a proxy or the client is using vpn?
In case 1, forward-for is enough.
In case 2, there should be no (normal) way to get real client IP. That's why people use a vpn. They want to hide their ip. See ipleak.net for more details.

songsammy avatar Oct 03 '21 09:10 songsammy

Or you mean, the server is in your organization and it is in a VPN, you need to know the quality of the vpn connection.
In that case you may need to use location API instead of getting an ip and calculate the distance.

songsammy avatar Oct 03 '21 11:10 songsammy

Or you mean, the server is in your organization and it is in a VPN, you need to know the quality of the vpn connection. In that case you may need to use location API instead of getting an ip and calculate the distance.

That's why I want to get the public IP from the client side I'll see if I can make some sense from that locationAPI

gustavoberman avatar Oct 12 '21 19:10 gustavoberman

The fact is that you can't (?) get the client IP (without a server)

songsammy avatar Nov 08 '21 16:11 songsammy