Sign in to follow this  
Followers 0
JackDinn

_getIP() , second method not working ?

14 posts in this topic

hi, sorry to have to post about _getIP() but iv had a search around and there's loads on resolving your public IP but its a lot of arguments on loads of different methods with loads of different offered scripts so im not really sure.

my prob is the _GetIP() func has to methods to retrieve your IP but in my case the second method just dont work ?

$ip="can not resolve"
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)
MsgBox(0, '', $ip)

I would like to know why "asking" whatismyip.com dont work?

The first method in the func using dyndns.org works (most of the time) but on occasion when it does not i wouldn't mind having the second method to take over, so to speak.

Also if there's a better way to get a public IP then please let me know but i'd be quite happy to just find out why whatismyip.com dont work.

Thx in advance :)


Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Dude very simple.

#include <INet.au3>
$ip = _INetGetSource("www.whatismyip.com/automation/n09230945.asp")
MsgBox(0,0, $ip)

You don't have to use that _getIP function as this does not create tmp files. :)

Edited by EndFunc

EndFuncAutoIt is the shiznit. I love it.

Share this post


Link to post
Share on other sites

wicked stuff , thx

i wonder why the UDF _GetIP() is still in there as thats what draws my attention when im looking to "get my IP" , o well no matter.

o but what would the address be for dyndns.org or any other that works? i really need 2 at least, unless the one you just gave will work 100%.

Many thx sir.


Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Share this post


Link to post
Share on other sites

The real truth is that AutoIt is banned from there. Devs here either don't know that or they don't care. I actually mentioned this long time ago. Will not go further analyzing why was I ignored.

For some period of time there was a warning returned and now the access is completely denied.

You need to change the user agent string.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

wicked stuff , thx

i wonder why the UDF _GetIP() is still in there as thats what draws my attention when im looking to "get my IP" , o well no matter.

o but what would the address be for dyndns.org or any other that works? i really need 2 at least, unless the one you just gave will work 100%.

Many thx sir.

That one will work as long as there site is available. :)

But you can use the other one as a fail safe. Try the one I showed you first and if its empty or returns an error have it use the other function.


EndFuncAutoIt is the shiznit. I love it.

Share this post


Link to post
Share on other sites

Hmm interesting, im sure its all long and drawn out so i wont ask for any elaboration :)

i wonder why there is not a way that does not involve "asking" another computer to tell me what my own public IP is?

anyhow you said "You need to change the user agent string" but to what? i dont know how you even start to find one.

cheers


Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

The real truth is that AutoIt is banned from there. Devs here either don't know that or they don't care. I actually mentioned this long time ago. Will not go further analyzing why was I ignored.

For some period of time there was a warning returned and now the access is completely denied.

You need to change the user agent string.

If you use the method I showed, it should work. Its no different than you browsing to the site. In fact, that's what that special URL is there for, that's how I discovered it. They don't want you to get the IP any other way but that URL.

Added reference.

http://forum.whatismyip.com/f19/support-for-cli-browsers-t468/

Edited by EndFunc

EndFuncAutoIt is the shiznit. I love it.

Share this post


Link to post
Share on other sites

If you use the method I showed, it should work. Its no different than you browsing to the site. In fact, that's what that special URL is there for, that's how I discovered it. They don't want you to get the IP any other way but that URL.

Added reference.

http://forum.whatismyip.com/f19/support-for-cli-browsers-t468/

I was talking about _GetIP() function from AutoIt's standard UDF.

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

I was talking about _GetIP() function from AutoIt's standard UDF.

Oh, I hear you. I guess it doesn't matter to them, who knows. But It does makes you wonder why you can't get your router IP except externally. Be nice if you didn't have to rely on a 3rd party.


EndFuncAutoIt is the shiznit. I love it.

Share this post


Link to post
Share on other sites

yep, :) even though were kinda talking over each other thats what i gathered you meant & thats just what im gonna be doing. Hopefully the "failsafe" _GetIP() wont be needed because it does hang for a while if it cant retrieve the ip but yea its a good idea to have it there just in case, especially as this is going into a public app and i like to get things all nice and neat if i can, dont like it sometimes hanging right at the launch as it has to know the ip before it starts the main gui.

I probably had better do a UDF with the two working parts as im sure i'll be wanting it again. np ;)

Cheers chaps B)


Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Share this post


Link to post
Share on other sites

yep, :) even though were kinda talking over each other thats what i gathered you meant & thats just what im gonna be doing. Hopefully the "failsafe" _GetIP() wont be needed because it does hang for a while if it cant retrieve the ip but yea its a good idea to have it there just in case, especially as this is going into a public app and i like to get things all nice and neat if i can, dont like it sometimes hanging right at the launch as it has to know the ip before it starts the main gui.

I probably had better do a UDF with the two working parts as im sure i'll be wanting it again. np ;)

Cheers chaps B)

Just an idea. If you want to rely on yourself. You can create your own .php page that shows a public IP address just like Whatismyip.com did and just use it for yourself/app. It's easy enough. So if you own your own webserver or have a host, then you will know that it's reliable since you'd be responsible for maintaining it.

That's what I would do if I was putting it in a public app. However whatismyip.com has been around a while so they are pretty reliable. But then you'd have 2 URL's you could query if you had your own too. B)


EndFuncAutoIt is the shiznit. I love it.

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Just an idea. If you want to rely on yourself. You can create your own .php page that shows a public IP address just like Whatismyip.com did and just use it for yourself/app. It's easy enough. So if you own your own webserver or have a host, then you will know that it's reliable since you'd be responsible for maintaining it.

That's what I would do if I was putting it in a public app. However whatismyip.com has been around a while so they are pretty reliable. But then you'd have 2 URL's you could query if you had your own too. :)

Example:

If you put this code on a blank page <? echo getenv('REMOTE_ADDR'); ?> and save it as say, ip.php and upload it to a webserver or local host if you use something like WAMP, then invoke it in a browser. It should do the exact same thing whatismyip.com shows you then you can use the earlier code the same way.

#include <INet.au3>

$ip = _INetGetSource("www.myownwebsite.com/ip.php")

MsgBox(0,0, $ip)

Edited by EndFunc

EndFuncAutoIt is the shiznit. I love it.

Share this post


Link to post
Share on other sites

well its a good idea, and i do have a webserver. However my main app thats getting a little busy atm is an internet speed tester. Now atm the users have to find there own ftp host to do upload testing but i have been teasing with the idea of using my web server to allow the users to do there upload speed tests but im a bit hesitant about using it because of the bandwidth requirement of all those uploads every half hour (or whatever).

But yea just doing the IP response is not a problem, just another thing for me to ponder on.


Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

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  
Followers 0