[squeak-dev] Figuring out external IP addresses of network interfaces

Ron Teitelbaum ron at usmedrec.com
Sun Mar 5 04:46:57 UTC 2017


HI all,

if you are running a web server you can use this to replace the
http://checkip.dyndns.com suggested by Edgar (Hi Edgar!):

<?php
$ip = getenv('HTTP_CLIENT_IP')?:
getenv('HTTP_X_FORWARDED_FOR')?:
getenv('HTTP_X_FORWARDED')?:
getenv('HTTP_FORWARDED_FOR')?:
getenv('HTTP_FORWARDED')?:
getenv('REMOTE_ADDR');
echo trim($ip);?>

This does a pretty good job of reporting back the IP address of a
connection from php.  I was using https://api.ipify.org/ but a number of
companies wrongly reported that as a virus and blocked it.  Having your own
code make it easier to get people to allow the connection especially if
they are adjusting proxy servers for your server addresses anyway.

I use the client IP address to calculate the distance from the client
connecting to each server so that I can select the closest one and reduce
latency.

All the best,

Ron Teitelbaum
www.3dicc.com



On Sat, Mar 4, 2017 at 3:21 PM Edgar De Cleene <edgardec2005 at gmail.com>
wrote:

> YES
> You could know your local and internet Ip
>
> I have this in Work (PasteUpMorph)
> reportPublicIP
> "Report the public IP of this computer
> World reportPublicIP."
>
> | addrString m s stream |
> stream := HTTPSocket httpGet: 'http://checkip.dyndns.com'.
> stream upToAll: 'IP Address: '.
> stream := stream upTo: $<.
> Socket initializeNetwork.
> addrString := stream upTo: $<.
> m := RectangleMorph new
> color: (Color r: 0.6 g: 0.8 b: 0.6);
> extent: 118 at 36;
> borderWidth: 1.
> s := StringMorph contents: 'Public IP:'.
> s position: m position + (5 at 4).
> m addMorph: s.
> s := StringMorph contents: addrString.
> s position: m position + (5 at 19).
> m addMorph: s.
> self primaryHand attachMorph: m.
>
> For local
>  Transcript show: NetNameResolver localHostAddress printString
>
> On Mar 4, 2017, at 14:40, Hari Balaraman <hari.balaraman at icloud.com>
> wrote:
>
> Hi All,
>
> I was wondering if there is a way to figure out the IP addresses of
> various network interfaces on a host machine. I've looked at some traffic
> on the list from a few years ago (6-7 years ago) that appeared to indicate
> there was no way to do this. As far as I could tell, there was a workaround
> using (running regularly) shell script that would write interface
> information to a file that could then be scooped up by the image.
>
> I was wondering if things have changed.
>
> I'd like an application to be aware of and be able to provide the IP
> address and port it is listening on for requests from the outside world
> (not localhost.)
>
> Thanks in advance.
>
> Kind regards,
>
> Hari
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20170305/a2a5f08e/attachment.html>


More information about the Squeak-dev mailing list