[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

file under "non-essential" (WServer)



This module (for 0.49+) looks up the software version (if it can) of a
specified webserver.  It requires the LWP::Simple module.


> webserver at www.infobot.org?
www.infobot.org is running "Apache/1.3.6 (Unix)  (Red Hat/Linux)"

> server for www.microsoft.com 
www.microsoft.com is running "Microsoft-IIS/5.0"

> What server is at http://www.novell.com?
http://www.novell.com is running "Netscape-Enterprise/3.5-For-NetWare"

Does novell still sell their own webserver?

Jay
(teckle)
package Infobot::Module::WServer;

use strict;
use Infobot::Module;

$Infobot::Module::WServer::VERSION = "0.01_00";
$Infobot::Module{"WServer"} = $Infobot::Module::WServer::VERSION;
@Infobot::Module::WServer::ISA = qw(Infobot::Module);

my $any_bad;

BEGIN {
  eval { require LWP::Simple };
  $@ and $any_bad = "LWP::Simple";
  warn "Infobot::Module::WServer requires $any_bad" if $any_bad;
}

sub Infobot::Module::WServer::new {
  my $class = shift ;
  return undef if $any_bad;

  my $self  = $class->SUPER::new(@_);
  $self->weight(0); 
  
  $self->enabled(1);
  $self->name('WServer');
  $self->regex(qr/server\s+(?:at|for|is\s+at)?\s*(\S+)/i);
  $self->usage('webserver at <site>');
  $self->descrip("Tries to lookup server running at site");

  bless $self, $class;
}

sub Infobot::Module::WServer::action {
    my ($self, $message) = @_;
    return undef unless $self->enabled;

    my $url = $message->get('args')->[0];
    my $orig = $url;
    $url = "http://".$url if ($url!~/^http:\/\//);
    $self->status(2,"looking up $url");
    # isn't good variable naming fundamental?
    my @stuff = LWP::Simple::head($url);
    if (@stuff) {
      return("$orig is running \"$stuff[$#stuff]\"");
    } else {
      return("Couldn't figure it out, sorry");
    }
}

1;

__END__

=head1 NAME

WServer -- looks up the server software for a given webserver.

=head1 SYNOPSIS

webserver at http://www.microsoft.com

server for www.infobot.org

what webserver is at www.securetty.org?

=head1 PREREQUISITES

	LWP::Simple

=head1 DESCRIPTION

	Shows the server software running at location specified.

=head1 AUTHORS

Jay Jacobs (teckle) <jjacobs@securetty.org>