From 17f941f1ee15c4490fed5aacf93f6f2bd728acc3 Mon Sep 17 00:00:00 2001 From: timriker Date: Tue, 11 Nov 2003 02:40:22 +0000 Subject: [PATCH] HTTPDtype from #php git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@873 c11ca15a-4712-0410-83d8-924469b57eb5 --- src/CommandStubs.pl | 3 +++ src/Modules/HTTPDtype.pl | 33 +++++++++++++++++++++++++++++++++ src/modules.pl | 1 + 3 files changed, 37 insertions(+) create mode 100644 src/Modules/HTTPDtype.pl diff --git a/src/CommandStubs.pl b/src/CommandStubs.pl index c37729a..bdcaf0b 100644 --- a/src/CommandStubs.pl +++ b/src/CommandStubs.pl @@ -248,6 +248,9 @@ sub parseCmdHook { 'Forker' => 1) ); &addCmdHook("extra", '(botmail|message)', ('CODEREF' => 'botmail::parse', 'Identifier' => 'botmail', 'Cmdstats' => 'botmail') ); +&addCmdHook("extra", 'httpdtype', ('CODEREF' => 'HTTPDtype::HTTPDtype', + 'Identifier' => 'httpdtype', 'Cmdstats' => 'httpdtype', + 'Forker' => 1) ); ### ### END OF ADDING HOOKS. diff --git a/src/Modules/HTTPDtype.pl b/src/Modules/HTTPDtype.pl new file mode 100644 index 0000000..3494846 --- /dev/null +++ b/src/Modules/HTTPDtype.pl @@ -0,0 +1,33 @@ +# HTTPDtype.pl: retrieves http server headers +# Author: Joey Smith +# Licensing: Artistic License +# Version: v0.1 (20031110) +# +use strict; + +package HTTPDtype; + +sub HTTPDtype { + my ($HOST) = @_; + my($line) = ''; + my($code, $mess, %h); + + $HOST = 'joeysmith.com' unless length($HOST) > 0; + return unless &::loadPerlModule("Net::HTTP::NB"); + return unless &::loadPerlModule("IO::Select"); + + my $s = Net::HTTP::NB->new(Host => $HOST) || return; + $s->write_request(HEAD => "/"); + + my $sel = IO::Select->new($s); + $line = "Header timeout" unless $sel->can_read(10); + ($code, $mess, %h) = $s->read_response_headers; + + $line = (length($h{Server}) > 0) ? $h{Server} : + "Couldn't fetch headers from $HOST"; + + &::pSReply($line||"Unknown Error Condition"); + +} + +1; diff --git a/src/modules.pl b/src/modules.pl index 3dbda58..05d22f3 100644 --- a/src/modules.pl +++ b/src/modules.pl @@ -55,6 +55,7 @@ if ($@) { "zippy" => "Zippy.pl", "zsi" => "zsi.pl", "botmail" => "botmail.pl", + "httpdtype" => "HTTPDtype.pl", ); ### THIS IS NOT LOADED ON RELOAD :( my @myModulesLoadNow; -- 2.39.5