-2

I am working on an application wherein I want to track clients public IP address. I don't want to use http://ipinfo.io as its an insecure connection.

Is it possible to get clients public IP address using core javascript?

Thanks

NKDev
  • 456
  • 3
  • 8
  • 23
  • are you talking about request.connection.remoteAddress – Vinay Prabhakaran Mar 02 '17 at 13:18
  • What is your backend language? If it's Node.js, you can use request.connection.remoteAddress like @VinayPrabhakaran said – Pyglouthon Mar 02 '17 at 13:22
  • My backend language is c# – NKDev Mar 02 '17 at 13:24
  • Why not track it from the server itself…? – deceze Mar 02 '17 at 13:27
  • You should have a look on how to get the ip client address from you C# code. Service like ipinfo or other are usefull to get geoip but you don't need the position in your case. It's better to avoid useless call to a third part service. If you are behind a loadbalancer, you can have a look on this [thread](http://stackoverflow.com/questions/19285957/how-to-get-the-public-ip-address-of-a-user-in-c-sharp) – Pyglouthon Mar 02 '17 at 13:36
  • @deceze I have two application one has java as backend and other has c#. I don't want to write logic to get ip address separately for both application hence i chose javascript. – NKDev Mar 02 '17 at 14:21
  • @SBillion I agree its good to avoid calls to third part service and clients firewall may block such calls. But if capturing public IP is not possible via js then may be i need to create something similar to ipinfo and call it from js. – NKDev Mar 02 '17 at 14:28
  • I don't understand what is the problem by having 2 application as backend. When do you want to track your user? Just do a basic endpoint which update the database with the ip if ip is not in the session. Call your backend like you wanted to call ipinfo. – Pyglouthon Mar 02 '17 at 14:40

1 Answers1

3

You could just use the https connection:

curl -v https://ipinfo.io

Or you can user an other service. There is a good list of services on this thread

Community
  • 1
  • 1
Pyglouthon
  • 552
  • 4
  • 15