]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
fix: TCPSocked.gethostbyname is deprecated main
authorHendrik Jäger <gitcommit@henk.geekmail.org>
Sun, 24 Sep 2023 19:44:17 +0000 (21:44 +0200)
committerHendrik Jäger <gitcommit@henk.geekmail.org>
Mon, 25 Sep 2023 18:17:12 +0000 (20:17 +0200)
data/rbot/plugins/url.rb

index e974c96b99042608da98829f82546ee4301781d5..934144cc6a0aadb5097a01747e9928e2c68da046 100644 (file)
@@ -3,6 +3,8 @@
 #
 # :title: Url plugin
 
+require 'socket'
+
 define_structure :Url, :channel, :nick, :time, :url, :info
 
 class UrlPlugin < Plugin
@@ -78,8 +80,7 @@ class UrlPlugin < Plugin
 
     # also check the ip, the canonical name and the aliases
     begin
-      checks = TCPSocket.gethostbyname(url.host)
-      checks.delete_at(-2)
+      checks = Addrinfo.getaddrinfo(url.host, nil).map { |addr| addr.ip_address }
     rescue => e
       return "Unable to retrieve info for #{url.host}: #{e.message}"
     end