Ok here my code. It works with Ruby 1.9 on my Arch Linux, i hope it be useful
=begin
GNU GPL v3
(C) Gerardo Gonzalez Cruz gerardogc2378@gmail.com
June 2011
=end
require 'ipaddr'
require 'net/http'
class Utils
def check_ip_on_dydns
con = Net::HTTP.new('checkip.dyndns.org', 80)
resp,body = con.get("/")
ip = body.match(/\d+\.\d+\.\d+\.\d+/)
ip[0]
end
def get_ip
return IPAddr.new(check_ip_on_dydns).to_s
end
end
references:
Happy Hackin'
=begin
GNU GPL v3
(C) Gerardo Gonzalez Cruz gerardogc2378@gmail.com
June 2011
=end
require 'ipaddr'
require 'net/http'
class Utils
def check_ip_on_dydns
con = Net::HTTP.new('checkip.dyndns.org', 80)
resp,body = con.get("/")
ip = body.match(/\d+\.\d+\.\d+\.\d+/)
ip[0]
end
def get_ip
return IPAddr.new(check_ip_on_dydns).to_s
end
end
references:
- http://checkip.dyndns.org/
- http://www.ruby-forum.com/
Happy Hackin'
Comentarios
Publicar un comentario