From 8df0fa618dc55e5c565d45b3b76aa8858a845097 Mon Sep 17 00:00:00 2001 From: timriker Date: Thu, 17 Feb 2005 03:58:03 +0000 Subject: [PATCH] nslookup -> dns as a forker git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@1130 c11ca15a-4712-0410-83d8-924469b57eb5 --- files/blootbot.help | 10 +++---- files/sample/blootbot.chan | 4 +-- files/sample/blootbot.config | 3 -- src/CommandStubs.pl | 3 ++ src/DynaConfig.pl | 10 ------- src/Modules/dns.pl | 54 ++++++++++++++++++++++++++++++++++++ src/UserExtra.pl | 48 -------------------------------- 7 files changed, 64 insertions(+), 68 deletions(-) create mode 100644 src/Modules/dns.pl diff --git a/files/blootbot.help b/files/blootbot.help index 790c813..2b843ea 100644 --- a/files/blootbot.help +++ b/files/blootbot.help @@ -165,6 +165,11 @@ dict: U: ## dict: E: ## AI dict: E: ## 1 linux +dns: D: Query DNS +dns: U: ## +dns: E: ## debian.org +dns: E: ## 3.1.33.7 + do: D: operator command to do things in a channel do: U: ## @@ -307,11 +312,6 @@ nickometer: U: ## {nick,channel} nickometer: E: ## unknown_lamer nickometer: E: ## #botpark -nslookup: D: Query DNS -nslookup: U: ## -nslookup: E: ## debian.org -nslookup: E: ## 3.1.33.7 - ord: D: Convert ascii to decimal ord: U: ## ord: E: ## c diff --git a/files/sample/blootbot.chan b/files/sample/blootbot.chan index e7c9233..e6220b7 100644 --- a/files/sample/blootbot.chan +++ b/files/sample/blootbot.chan @@ -1,4 +1,4 @@ -#v1: blootbot -- infobot -- written Thu Feb 17 03:17:32 2005 +#v1: blootbot -- infobot -- written Thu Feb 17 03:57:07 2005 #botpark +RootWarn @@ -39,7 +39,6 @@ _default +Weather +Zippy +allowConv - +allowDNS +allowTelling +babelfish +botmail @@ -49,6 +48,7 @@ _default +cookie +countdown debianRefreshInterval 7 + +dns +factoidArguments floodMessages 10:30 floodRepeat 2:10 diff --git a/files/sample/blootbot.config b/files/sample/blootbot.config index f8b072f..2dde025 100644 --- a/files/sample/blootbot.config +++ b/files/sample/blootbot.config @@ -171,9 +171,6 @@ set Math 1 # [0/1] ord/chr etc set allowConv 1 -# [0/1] do you want to allow DNS lookup -set allowDNS 1 - # [0/1] Forking... disable for non-nix OS or to reduce mem usage. # Disabling should make the bot work on Win32 and MacOS. set forking 1 diff --git a/src/CommandStubs.pl b/src/CommandStubs.pl index b007d36..e153fce 100644 --- a/src/CommandStubs.pl +++ b/src/CommandStubs.pl @@ -280,6 +280,9 @@ sub parseCmdHook { &addCmdHook("extra", '[ia]?spell', ('CODEREF' => 'spell::query', 'Identifier' => 'spell', 'Cmdstats' => 'spell', 'Forker' => 1, 'Help' => 'spell') ); +&addCmdHook("extra", 'dns|d?nslookup|host', ('CODEREF' => 'dns::query', + 'Identifier' => 'dns', 'Cmdstats' => 'dns', + 'Forker' => 1, 'Help' => 'dns') ); ### ### END OF ADDING HOOKS. ### diff --git a/src/DynaConfig.pl b/src/DynaConfig.pl index 8052267..c5d9aa7 100644 --- a/src/DynaConfig.pl +++ b/src/DynaConfig.pl @@ -828,16 +828,6 @@ sub rehashConfVars { delete $cache{confvars}; } -# registered flags... not used yet. -my @regFlagsChan = ( - "autojoin", - "limitcheckInterval", - "limitcheckPlus", - "allowConv", - "allowDNS", -### TODO: finish off this list. -); - my @regFlagsUser = ( # possible chars to include in FLAG "A", # bot administration over /msg diff --git a/src/Modules/dns.pl b/src/Modules/dns.pl new file mode 100644 index 0000000..73369eb --- /dev/null +++ b/src/Modules/dns.pl @@ -0,0 +1,54 @@ +# +# dns.pl: host lookups +# Author: Tim Riker +# Source: extracted from UserExtra.pl +# Licensing: Artistic License (as perl itself) +# Version: v0.1 +# +# Copyright (c) 2005 Tim Riker +# + +package dns; + +use strict; + +sub dns::dns { + my $dns = shift; + my($match, $x, $y, $result, $pid); + + if ($dns =~ /(\d+\.\d+\.\d+\.\d+)/) { + use Socket; + + &main::status("DNS query by IP address: $dns"); + + $y = pack('C4', split(/\./, $dns)); + $x = (gethostbyaddr($y, &AF_INET)); + + if ($x !~ /^\s*$/) { + $result = "$dns is $x" unless ($x =~ /^\s*$/); + } else { + $result = "I can't find the address $dns in DNS"; + } + + } else { + + &main::status("DNS query by name: $dns"); + $x = join('.',unpack('C4',(gethostbyname($dns))[4])); + + if ($x !~ /^\s*$/) { + $result = "$dns is $x"; + } else { + $result = "I can't find $dns in DNS"; + } + } + + return($result); +} + +sub dns::query { + &::performStrictReply(&dns(@_)); + return; +} + +1; +# vim: ts=2 sw=2 diff --git a/src/UserExtra.pl b/src/UserExtra.pl index 584a43b..9d27eb9 100644 --- a/src/UserExtra.pl +++ b/src/UserExtra.pl @@ -26,9 +26,6 @@ use vars qw(%channels %chanstats %cmdstats %count %ircstats %param &addCmdHook("main", 'help', ('CODEREF' => 'help', 'Cmdstats' => 'Help', ) ); &addCmdHook("main", 'karma', ('CODEREF' => 'karma', ) ); -&addCmdHook("main", 'd?nslookup', ('CODEREF' => 'DNS', - Help => 'nslookup', Identifier => 'allowDNS', - Forker => "NULL", ) ); &addCmdHook("main", 'tell|explain', ('CODEREF' => 'tell', Help => 'tell', Identifier => 'allowTelling', Cmdstats => 'Tell') ); @@ -234,12 +231,6 @@ sub karma { } } -sub nslookup { - my $query = shift; - &status("DNS Lookup: $query"); - &DNS($query); -} - sub tell { my $args = shift; my ($target, $tell_obj) = ('',''); @@ -350,45 +341,6 @@ sub tell { &msg($target, $reply); } -sub DNS { - my $dns = shift; - my($match, $x, $y, $result); - my $pid; - $dns =~ s/^\s+|\s+$//g; - - if (!defined $dns or $dns =~ /^\s*$/ or $dns =~ / /) { - &help("dns"); - return; - } - - if ($dns =~ /(\d+\.\d+\.\d+\.\d+)/) { - $match = $1; - &status("DNS query by IP address: $match"); - - $y = pack('C4', split(/\./, $match)); - $x = (gethostbyaddr($y, &AF_INET)); - - if ($x !~ /^\s*$/) { - $result = $match." is ".$x unless ($x =~ /^\s*$/); - } else { - $result = "I can't seem to find that address in DNS"; - } - - } else { - - &status("DNS query by name: $dns"); - $x = join('.',unpack('C4',(gethostbyname($dns))[4])); - - if ($x !~ /^\s*$/) { - $result = $dns." is ".$x; - } else { - $result = "I can\'t find that machine name"; - } - } - - &performReply($result); -} - sub countryStats { if (exists $cache{countryStats}) { &msg($who,"countrystats is already running!"); -- 2.39.5