How JavaScript can obtain IP, where as people using a proxy? - javascript

Can you say how to website can can obtain real IP user with JavaScript, whereas people using a proxy, please?
Thanks

Client-side Javascript cannot, by itself, obtain your IP address. And, even if it did, what it would likely see is an internal network IP address, not a public IP address.
So, the only way to get the IP address from plain Javascript is to ask a server to tell you what your IP address is. You make an Ajax request to the server with a request that tells the server you want it to return what your IP address is. The server can then return the IP address that it sees your connection coming from. This address will be your outwards-facing public IP address. Since most client computers these days are behind some sort of router/firewall, what the server is probably seeing is a single public IP address that is being NATed from your actual client computer.
If there was a proxy server in the route between my client computer and the server, then the server would see the IP address of the proxy server, not the IP address of the client computer. And, there is nothing you can do to change that. Proxies and routers are specific designed to map one set of private IP addressing to a public IP addresses while keeping the network topology of the private network completely hidden from the outside world.
For example, the actual IP address of my local computer right now is 192.168.1.17 which is a local IP address on my home network. But, when I ask a server out on the internet what my IP address is using a service like http://whatismyipaddress.com/, then it reports the actual public IP address that Comcast has assigned to my router which is 67.180.86.xxx. When I make a connection to the internet from my local computer, that connection goes first to the router where the router uses NAT (network address translation) to map this connection between my private IP address on the home network and a particular outgoing TCP connection from my public IP address. When packets flow back on that connection, the router forwards those packets to my private IP address on the home network.

I know that it is possible. Tor broswer, block JavaScrip beacause they can obtain real public IP address of client. And I would know how to JavaScript can obtain ,the real public IP adress, whereas user use a proxy server.

Related

For websocket connection in javascript if wants to communicate to other device how I can get IP address which I can pass through websocket connection?

var ip = "";
var ws = new WebSocket("ws://"+ip+":9998");
It is not possible to find private IP address. or I need any server side language like node.js?
You would need to know the IP address in order to do that. There is no way of figuring out the IP address of other clients. If you wanted to connect to another socket without knowing the IP address you would use a server to connect the endpoints and route the messages.

Client IP Address in Angular

I need to obtain client local IP address into internal network not the IP over internet by angular for some reason that data will send to IP address over network not based on authorization,I googled so much and I can just find the IP over internet,
Now how can I solve this issue? thanks
Client IP address cannot be accessible by you or with any NPM from front end.
U can find different IP's over internet don't use it.
If you want the client IP, can only be accessed in Node.js.
NPM - request-ip

XMLHttp​Request get ip of url

For example i send a request to https://www.w3schools.com/ which is showed Remote Address: 192.229.179.87:443 on Inspect tools, can i get that ip in js?
An IP address or Internet Protocol is used in hand with TCP(Transmission control protocol) to identify and share information between computers on the internet. Because it would be a very hard job for humans to keep IP's of various servers in the head, all IP addresses are saved on a DNS server together with their domain names. Hence, whenever you make a request to a site in your web browser, the web browser first visits a DNS server to fetch the IP address corresponding to your domain before making a direct request to the server. Hence there is no Javascript code or command to generate IP addresses from domain names. Hence to accomplish this, you'll have to use an API which will do all the hard work for you.
Check this question for some API's : API's for getting IP

Connecting socket.io client to different hosting

So a website of mine is hosted on godaddy, now I want to connect it with a server that is running socket.io, and I have some balance on digitalocean. However, I am not sure how I would do this, I think it should be like this for client side?
var socket = io.connect('http://Digital.ocean.ip.here:port');
and then server side like this
http.listen(port, function(){
console.log('listening on *:port');
});
the only thing is that if this is how I am supposed to do it (and it even is possible if it's not the localhost), than users will be able to see the ip of my droplet when they take a look in the source code, and perhaps DDOS it or maybe worse I don't know?
When I see other sites using socket.io for a chat for instance, I never see their IP. Does that mean they host their entire website on a service provider where they are able to use socket.io/node.js?
Any answer will be highly appreciated!
--Edit--
My client wouldn't accept http and therefore I decided to buy a domain and ssl so it would use https.
There's no way to every hide the IP address of a server that a browser connects to. It makes no difference whether the connection to the server is http or socket.io or any other TCP based connection. Anyone can see the IP address. So, that simply isn't something you can protect or should worry about.
In most cases, code will use a DNS host name (not an IP address), but the DNS service itself provides a way to lookup the IP address for a host name so the IP address can be fetched that way. Or, one can just load a debugger or local network snooper and easily see what IP address is being connected to. A host's IP address is simply not a secret.
If you are worried about DDOS, then you will have to implement server-side protection from those types of attacks. You can't do anything in the client to protect from those kinds of attacks.

How does google obtain the IP address they report for "Last Account Actiivty"

Can anybody let me know the logic they use to get the IP?
The server has to know your IP address to send you a response. That is how the internet works. Presumably they store the IP address for the last account activity in a database somewhere.
When your browser connects to their web site, their HTTP server determines the IP address from the connected socket. That IP address is supplied to Google's web application framework, which stores the IP address in some kind of data store, so that it can be retrieved later. I can't give you much more detail, since I don't work for Google (and even if I did, I probably wouldn'couldn't).
request.getRemoteHost();
this method in the request object will return the ip address of the client.

Categories