This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

HL Public IP script
#1
Hi,

Until now I've used this script for the public IP change on HL:
Code:
12345678910111213
ip_old = grp.getvalue('10/1/253') require("socket.http") myip = (socket.http.request("http://whatismyip.org/")) ip = myip:match("[%font%-weight%: 600;\"%>](%d+%.%d+%.%d+%.%d+)") if ip ~= ip_old then  subject = 'HL has New Public IP'  message = ip  Email('my@email.com', subject, message) end grp.checkwrite('10/1/253', ip,dt.string)

Unfortunately whatismyip.org is closed and the script is not working.

Then I created this one:
Code:
123456789101112
ip_old = grp.getvalue('10/1/253') require("socket.http") ip = (socket.http.request("https://api.ipify.org")) if ip ~= ip_old then  subject = 'HL has New Public IP'  message = ip  Email('my@email.com', subject, message) end grp.checkwrite('10/1/253', ip, dt.string)

The csript is working in SciTE (or similar) in this version:
Code:
123
require("socket.http") ip = (socket.http.request("https://api.ipify.org")) print (ip)
but NOT in HL.

What do I do wrong?!?
Reply
#2
Try this:

Code:
123456789101112131415161718
require('socket.http') socket.http.TIMEOUT = 5 local data = socket.http.request('http://api.ipify.org') if not data then return log('No response getting IP') end ip_old = storage.get('ip_old') if ip_old == nil then storage.set('ip_old', data) end if data ~= ip_old then storage.set('ip_old', data) log('IP changed, new IP is: ' .. data) end
Reply
#3
Working perfect.
Thank you FatMax!!!
Reply
#4
You can remove the require(‘json’) because the script does not use it..

BR,

Erwin
Reply
#5
Removed.

It was there for other purposes of the script..
Reply
#6
Code:
12345678910111213141516171819202122232425
require('socket.http') socket.http.TIMEOUT = 5 local data = socket.http.request('http://api.ipify.org') if not data then return log('No response getting IP') end ipPublic_old = storage.get('ipPublic_old') if ipPublic_old == nil then storage.set('ipPublic_old', data) end if data ~= ipPublic_old then storage.set('ipPublic_old', data) log('IP changed, new IP is: ' .. data) end if data ~= ipPublic_old then    subject = 'IP Pública'   message = 'La nueva ip pública es: ' .. data   mail('xxxxxxxxxxxx', subject, message)   storage.set('ipPublic_old', data) end




Hi, I'm using this script and lately it was working fine but now I get notifications every little time (1-2 hours) and the IP has not changed. I receive an email notifying that the IP has changed but it appears blank, and after 60 seconds a second notification arrives with the same IP that I had previously.
Reply
#7
Maybe run it less often, they might implement some limits.
------------------------------
Ctrl+F5
Reply
#8
(01.03.2021, 15:40)davidchispas Wrote:
Code:
12345678910111213141516171819202122232425
require('socket.http') socket.http.TIMEOUT = 5 local data = socket.http.request('http://api.ipify.org') if not data then return log('No response getting IP') end ipPublic_old = storage.get('ipPublic_old') if ipPublic_old == nil then storage.set('ipPublic_old', data) end if data ~= ipPublic_old then storage.set('ipPublic_old', data) log('IP changed, new IP is: ' .. data) end if data ~= ipPublic_old then    subject = 'IP Pública'   message = 'La nueva ip pública es: ' .. data   mail('xxxxxxxxxxxx', subject, message)   storage.set('ipPublic_old', data) end




Hi, I'm using this script and lately it was working fine but now I get notifications every little time (1-2 hours) and the IP has not changed. I receive an email notifying that the IP has changed but it appears blank, and after 60 seconds a second notification arrives with the same IP that I had previously.

Did you solve the problem?
Reply


Forum Jump: