Jump to content
Sign in to follow this  
qwertylol

how did it do that ?!

Recommended Posts

qwertylol

#include <Inet.au3>

$PublicIP = _GetIP()

MsgBox(0, "IP Address", "Your IP Address is: " & $PublicIP)

I thought this was gonna return something like 192.168.x.x , since I am using a router between my computers and my modem, you know?

instead it returned my modem's ip.

so, did au3 access an outside server and determined my ip on the router as my "public" ip address?

I just wanted the lan up...

what went wrong ?

Share this post


Link to post
Share on other sites
evilertoaster

sure did-

Func _GetIP()
    Local $ip, $t_ip
    If InetGet("http://checkip.dyndns.org/?rnd1=" & Random(1, 65536) & "&rnd2=" & Random(1, 65536), @TempDir & "\~ip.tmp") Then
        $ip = FileRead(@TempDir & "\~ip.tmp", FileGetSize(@TempDir & "\~ip.tmp"))
        FileDelete(@TempDir & "\~ip.tmp")
        $ip = StringTrimLeft($ip, StringInStr($ip, ":") + 1)
        $ip = StringTrimRight($ip, StringLen($ip) - StringInStr($ip, "/") + 2)
        $t_ip = StringSplit($ip, '.')
        If $t_ip[0] = 4 And StringIsDigit($t_ip[1]) And StringIsDigit($t_ip[2]) And StringIsDigit($t_ip[3]) And StringIsDigit($t_ip[4]) Then
            Return $ip
        EndIf
    EndIf
    If InetGet("http://www.whatismyip.com/?rnd1=" & Random(1, 65536) & "&rnd2=" & Random(1, 65536), @TempDir & "\~ip.tmp") Then
        $ip = FileRead(@TempDir & "\~ip.tmp", FileGetSize(@TempDir & "\~ip.tmp"))
        FileDelete(@TempDir & "\~ip.tmp")
        $ip = StringTrimLeft($ip, StringInStr($ip, "Your ip is") + 10)
        $ip = StringLeft($ip, StringInStr($ip, " ") - 1)
        $ip = StringStripWS($ip, 8)
        $t_ip = StringSplit($ip, '.')
        If $t_ip[0] = 4 And StringIsDigit($t_ip[1]) And StringIsDigit($t_ip[2]) And StringIsDigit($t_ip[3]) And StringIsDigit($t_ip[4]) Then
            Return $ip
        EndIf
    EndIf
    SetError(1)
    Return -1
EndFunc   ;==>_GetIP

You can see teh addresses it uses...

Share this post


Link to post
Share on other sites
qwertylol

aw gdi, I called the unfamiliar function knowing only its crappy description from the help file :shocked:

so, how do I find out my lan ip?

thanks !

Share this post


Link to post
Share on other sites
BigDod

Try

MsgBox(0,"IP Address", @IPAddress1)

BTW

The help file does say that it returns the public IP address, so please do not call it crappy just because you do not understand what public means.



Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites
PsaltyDS

I do think the help file should mention that using the _GetIP() function causes your computer to talk to an outside web site to get the data. That could be very critical information in some situations. Maybe it's just me, but that looks on casual reading like it should be an internal process, similar to the @IPAddress1 macro. I get that an external IP discovery site is required to see your address outside the NATs and/or Proxies in place, it should just be clearly mentioned in the help file.

:(

P.S. I put a topic in Bug Reports to recommend updating the Remarks for _GetIP() in the help file to:

Remarks

This only returns the Public IP address of a computer or network (i.e. the public IP on the WAN link of your NAT router). The address is determined by accessing an external IP discovery web site like checkip.dyndns.org or www.whatismyip.com.

:shocked:

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
qwertylol

so how about the lan ip ?

thanks !

Share this post


Link to post
Share on other sites
qwertylol

I found it under the helpfile in

Macro Reference - System Info

@IPAddress1

Share this post


Link to post
Share on other sites
clifox

Try

MsgBox(0,"IP Address", @IPAddress1)

BTW

The help file does say that it returns the public IP address, so please do not call it crappy just because you do not understand what public means.

You had this answer from 4 hours ago!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.