X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=data%2Frbot%2Fplugins%2Fnslookup.rb;h=a3402711d41441d9347b2a2a17bd806006d18b27;hb=90656f4203a0a989b6fb110d4a07598dd186b84c;hp=160fee85f7aa133ce1d0673505e14ce8dccde2bb;hpb=676dd61e6b0bea5f506d064039a685944aefd6fb;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/data/rbot/plugins/nslookup.rb b/data/rbot/plugins/nslookup.rb index 160fee85..a3402711 100644 --- a/data/rbot/plugins/nslookup.rb +++ b/data/rbot/plugins/nslookup.rb @@ -10,34 +10,30 @@ class DnsPlugin < Plugin def help(plugin, topic="") "dns => show local resolution results for hostname or ip address" end - + def name_to_ip(m, params) - Thread.new do - begin - a = getaddresses(params[:host]) - if a.length > 0 - m.reply m.params + ": " + a.join(", ") - else - m.reply "#{params[:host]}: not found" - end - rescue StandardError => err + begin + a = getaddresses(params[:host]) + if a.length > 0 + m.reply m.params + ": " + a.join(", ") + else m.reply "#{params[:host]}: not found" end + rescue StandardError => err + m.reply "#{params[:host]}: not found" end end - + def ip_to_name(m, params) - Thread.new do - begin - a = gethostname(params[:ip]) - m.reply m.params + ": " + a if a - rescue StandardError => err - m.reply "#{params[:ip]}: not found (does not reverse resolve)" - end - end + begin + a = gethostname(params[:ip]) + m.reply m.params + ": " + a if a + rescue StandardError => err + m.reply "#{params[:ip]}: not found (does not reverse resolve)" + end end end plugin = DnsPlugin.new -plugin.map 'dns :ip', :action => 'ip_to_name', +plugin.map 'dns :ip', :action => 'ip_to_name', :thread => true, :requirements => {:ip => /^\d+\.\d+\.\d+\.\d+$/} -plugin.map 'dns :host', :action => 'name_to_ip' +plugin.map 'dns :host', :action => 'name_to_ip', :thread => true