Facing IP address block?

I can return the local ip of the client but can't figure a way to get the facing ip. Any suggestions?

[110 byte] By [Stephen2007] at [2008-2-24]
# 1
Not sure if i understand what you mean by facing IP? Could you elaborate?
AndyS at 2007-9-26 > top of Msdn Tech,Popfly,Popfly General Discussion...
# 2

Think he means his WAN or ISP IP address.

For example returning a users online / external ip address so that its location can be resolved in virtual earth etc.

jonathan.gledhill at 2007-9-26 > top of Msdn Tech,Popfly,Popfly General Discussion...
# 3

Right. The external ip instead of the ip on a LAN.

Using InetAddress I can get the ip of the machine within its local area but I can't figure out a way to get the external ip.

Stephen2007 at 2007-9-26 > top of Msdn Tech,Popfly,Popfly General Discussion...
# 4
Ah, that's actually harder than it sounds as you don't have access to the property in javascript and as we proxy cross domain requests if you did getText on something like whatismyip.org you would actually get the IP address of our proxy. However there is a way around this as we have a page that returns the IP address of the client. You can use the following code in a block or in advanced code to get access to this:
Code Snippet

var httpRequest = new window.XMLHttpRequest();
var url = "/Content/Components/Resources/WhatIsMyIP.aspx";
httpRequest.open("GET", url, false);
httpRequest.send(null)
var ip = httpRequest.responseText;

AndyS at 2007-9-26 > top of Msdn Tech,Popfly,Popfly General Discussion...
# 5
Excellent. Thanks! Just as soon as I get back to my machine I'll give it a try!
Stephen2007 at 2007-9-26 > top of Msdn Tech,Popfly,Popfly General Discussion...
# 6

Thanks for the great solution!

I've been working on something very similar for my first block, but I had to do some bad workarounds because I was not aware that there was an aspx file on the Popfly server to get the "real" ip address.

I hope you guys don't mind if I built a simple block based on your code

SkyD at 2007-9-26 > top of Msdn Tech,Popfly,Popfly General Discussion...
# 7

That's fine we had put in their for this :-).

hostip.info have a nice web service which looks up address info based on IP address.

AndyS at 2007-9-26 > top of Msdn Tech,Popfly,Popfly General Discussion...