From ff949fe1c9dd0c179ecdce9340c04c05242d3a48 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Sun, 3 Aug 2008 10:03:36 +0200 Subject: iplookup plugin: support IPv6 too This is achieved by moving the check for IP vs hostname in the iplookup() method itself, and using the existing regexps to check if a string is an IP or not. --- data/rbot/plugins/iplookup.rb | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/data/rbot/plugins/iplookup.rb b/data/rbot/plugins/iplookup.rb index 87c94699..a53b16e4 100644 --- a/data/rbot/plugins/iplookup.rb +++ b/data/rbot/plugins/iplookup.rb @@ -188,8 +188,10 @@ class IPLookupPlugin < Plugin end def iplookup(m, params) - reply = "" - if params[:domain] + debug params + if params[:domain].match(/^#{Regexp::Irc::HOSTADDR}$/) + ip = params[:domain] + else begin ip = Resolv.getaddress(params[:domain]) reply += "#{params[:domain]} | " @@ -197,8 +199,6 @@ class IPLookupPlugin < Plugin m.reply "#{e.message}" return end - else - ip = params[:ip] end reply += ArinWhois.lookup_info(ip) @@ -214,8 +214,7 @@ class IPLookupPlugin < Plugin end plugin = IPLookupPlugin.new -plugin.map 'iplookup :ip', :action => 'iplookup', :requirements => {:ip => /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/}, :thread => true -plugin.map 'iplookup :domain', :action => 'iplookup', :requirements => {:domain => /^[a-z0-9\.\-]{4,255}$/i}, :thread => true +plugin.map 'iplookup :domain', :action => 'iplookup', :thread => true plugin.map 'userip :user', :action => 'userip', :requirements => {:user => /\w+/}, :thread => true -- cgit v1.2.3