view release on metacpan or search on metacpan
Revision history for Agent::TCLI::Package::Net
0.031 Thu Jun 7 20:40:10 EST 2007
- Fixed up more POD errors
- Fixed bug in SMTP when failing to send, created dev test
- Turned off some debugging in SMTP that was left on.
- Added SMTP sendmsg command
0.03 Thu Jun 7 06:42:00 EST 2007
- Added SMTP client package
- Cleaned up some PODs
0.02 Thu May 3 14:04:37 EST 2007
- updated tests for TCLI-Core 0.03
lib/Agent/TCLI/Package/Net.pm view on Meta::CPAN
1;
#__END__
=head1 AUTHOR
Eric Hacker E<lt>hacker at cpan.orgE<gt>
=head1 BUGS
This is only documentation, but there is probably a speeling error or a
grammer mistake lurking about.
=head1 LICENSE
Copyright (c) 2007, Alcatel Lucent, All rights resevred.
This package is free software; you may redistribute it
and/or modify it under the same terms as Perl itself.
=cut
lib/Agent/TCLI/Package/Net/HTTPD.pm view on Meta::CPAN
Agent::TCLI::Command:
name: stop
call_style: session
command: tcli_httpd
contexts:
httpd: stop
handler: stop
help: Stops a running http server on a particular port
manual: >
The stop command stops an httpd listener running on the specified port. It
will return an error if the port cannot be found in the list of servers
running.
parameters:
port:
required:
port:
topic: net
usage: httpd stop port=8080
---
Agent::TCLI::Command:
name: uri
lib/Agent/TCLI/Package/Net/HTTPD.pm view on Meta::CPAN
$response->content( 'OK' );
$kernel->call( $self->name => 'Log' => $request, $response ) if $self->logging;
$kernel->post('HTTPD'.$port, 'DONE', $response );
}
=item NA404
This POE Event handler is used as a target event for URIs. It will
send an HTTP response code of 404 with an error message.
It will log the conenction if logging is turned on.
=cut
sub NA404 {
# ARG0 = HTTP::Request object, ARG1 = HTTP::Response object,
# ARG2 = the DIR that matched
my ($kernel, $self, $request, $response, $dirmatch ) =
@_[KERNEL, OBJECT, ARG0 .. ARG2 ];
my $port = $response->connection->local_port;
# Check for errors
if ( ! defined $request ) {
$_[KERNEL]->post( 'HTTPD'.$port, 'DONE', $response );
return;
}
# Do our stuff to HTTP::Response
$response->code( 404 );
$response->content( "Hi visitor from " . $response->connection->remote_ip.
", Page not found -> '" . $request->uri->path . "'" );
lib/Agent/TCLI/Package/Net/Ping.pm view on Meta::CPAN
$self->Verbose("ping: target(".$target.") ",2);
# only one ping per host at a time
if (defined($self->requests->{$target->addr}{'request'} ))
{
$self->Verbose('ping: ping in progress for target');
$request->Respond($kernel,"Error: ping already in progress for ".$target,409);
return;
}
# $txt will be populated if there was an error.
if ($txt)
{
$self->Verbose('dos: argument error '.$txt);
$request->Respond($kernel, $txt,412);
return;
}
$self->requests->{$target->addr}{'request'} = $request;
# execution
$kernel->post( 'pinger' => 'ping' => 'Pong' =>
$target->addr,
lib/Agent/TCLI/Package/Net/Traceroute.pm view on Meta::CPAN
$self->Verbose("trace: target(".$param->{'target'}.") \n",2);
# only one traceroute per host at a time
if (defined($self->requests->{$param->{'target'}->addr}{'request'} ))
{
$self->Verbose('trace: trace in progress for target'.$param->{'target'}->addr);
$request->Respond($kernel,"trace already in progress for ".$param->{'target'}->addr,409);
return;
}
# $txt will be populated if there was an error.
if ($txt)
{
$self->Verbose('trace: argument error '.$txt);
$request->Respond($kernel, $txt,412);
return;
}
my @trace_options;
push(@trace_options,
'MaxTTL' => $param->{'max_ttl'},
'FirstHop' => $param->{'firsthop'},
'Timeout' => $param->{'timeout'},
'QueryTimeout' => $param->{'querytimeout'},
lib/Agent/TCLI/Package/Net/Traceroute.pm view on Meta::CPAN
This POE event handler processes the return data from the PoCo::Client::Traceroute.
=cut
sub TraceResponse {
my ($kernel, $self, $trace, $reply) =
@_[KERNEL, OBJECT, ARG0, ARG1];
my ($destination, $options, $callback) = @$trace;
my ($hops, $data, $error) = @$reply;
$self->Verbose("TraceResponse: destination(".$destination.")");
my ($txt,$code);
my $request = delete($self->requests->{$destination}{'request'});
# define code first, so that error can include hops that might
# have been successful.
$code = 200;
if ($error)
{
$txt = "trace failed for ".$destination.": ".$error;
$code = 400; # request_timeout
}
# Hops are returned whether success of failure.
if ($hops)
{
$txt .= "Traceroute results for $destination\n";
foreach my $hop (@$data)
{
lib/Agent/TCLI/Package/Net/Traceroute.pm view on Meta::CPAN
This POE event handler processes the per hop return data from the
PoCo::Client::Traceroute.
=cut
sub TraceHopResponse {
my ($kernel, $self, $trace, $reply) =
@_[KERNEL, OBJECT, ARG0, ARG1];
my ($destination, $options, $callback) = @$trace;
my ($hops, $data, $error) = @$reply;
$self->Verbose("TraceResponse: destination(".$destination.")");
my ($txt,$code);
my $request = delete($self->requests->{$destination}{'request'});
# define code first, so that error can include hops that might
# have been successful.
$code = 206; # partial content
if ($error)
{
$txt = "trace failed for ".$destination.": ".$error;
$code = 400; # request_timeout
}
# Hops are returned whether success of failure.
if ($hops)
{
$txt .= "Traceroute results for $destination\n";
foreach my $hop (@$data)
{
lib/Agent/TCLI/Package/Net/Traceroute.pm view on Meta::CPAN
Agent::TCLI::Parameter:
name: max_ttl
constraints:
- UINT
default: 30
help: Set the maximum TTL.
manual: >
Maxttl sets the maximum TTL for the traceroute. Once this many hops
have been attempted, if the target has still not been reached, the
traceroute finishes and a 'MaxTTL exceeded without reaching target'
error is returned along with all of the data collected. max_ttl
defaults to 32 and can not be set higher than 255.
type: Param
class: numeric
---
Agent::TCLI::Parameter:
name: timeout
constraints:
- UINT
default: 0
help: Set global timeout in seconds.
manual: >
Timeout sets the maximum time any given traceroute will run. After
this time the traceroute will stop in the middle of where ever it
is and a 'Traceroute session timeout' error is returned along with
all of the data collected. Timeout defaults to 0, which disables
it completely.
type: Param
class: numeric
---
Agent::TCLI::Parameter:
name: querytimeout
constraints:
- UINT
default: 3
t/TCLI.Package.Net.HTTP.t view on Meta::CPAN
$poe_td = 0 unless defined($poe_td);
$poe_te = 0 unless defined($poe_te);
sub POE::Kernel::TRACE_DEFAULT () { $poe_td }
sub POE::Kernel::TRACE_EVENTS () { $poe_te }
use POE;
use Agent::TCLI::Transport::Test;
use Agent::TCLI::Testee;
# TASK Test suite is not complete. Need testing for catching errors.
use_ok('Agent::TCLI::Package::Net::HTTP');
my $testee = "http";
# Need to use the test-builder for diagnostic output instead of printing
# Using a ref to verbose to support dynamic changing of verbosity while running
my $test1 = Agent::TCLI::Package::Net::HTTP->new({
'verbose' => \$verbose,
'do_verbose' => sub { diag( @_ ) },
t/TCLI.Package.Net.HTTPD.t view on Meta::CPAN
sub POE::Kernel::TRACE_DEFAULT () { $poe_td }
sub POE::Kernel::TRACE_EVENTS () { $poe_te }
use POE;
use Agent::TCLI::Transport::Test;
use Agent::TCLI::Testee;
use Agent::TCLI::Package::Net::HTTP;
use Agent::TCLI::Package::Tail;
# TASK Test suite is not complete. Need testing for catching errors.
use_ok('Agent::TCLI::Package::Net::HTTPD');
my $testee = "httpd";
# Need to use the test-builder for diagnostic output instead of printing
# Using a ref to verbose to support dynamic changing of verbosity while running
my $test1 = Agent::TCLI::Package::Net::HTTPD->new({
'verbose' => \$verbose,
'do_verbose' => sub { diag( @_ ) },
t/TCLI.Package.Net.HTTPD.t view on Meta::CPAN
$t->ok('/http cget url=http://127.0.0.1:8080/bar.htm');
$t->ok('/tail test add like 404.*?foo');
$t->ok('/http cget url=http://127.0.0.1:8080/foo.htm');
$t->ok('/tail test add like 200.*?foobar');
$t->ok('/http cget url=http://127.0.0.1:8080/foobar.htm');
$t->ok('stop' );
$t->ok('uri delete regex=bar.*');
$t->unlike_body('show handlers',qr(bar),'bar gone');
# test for error on restarting on same port
$t->ok('spawn port 8000' );
$t->ok('/http cget url=http://127.0.0.1:8000/foo.htm','HTTPD up');
$t->not_ok('spawn port 8000' );
$t->not_ok('stop' );
$t->ok('stop port 8000' );
# Can't add handler after server up yet. Need to fix SimpleHTTP
# 13 tests
#$t->ok('spawn' );
#$t->ok('uri add regex=bar.*');
t/TCLI.Package.Net.Ping.t view on Meta::CPAN
$poe_td = $opt->get_poe_debug;
$poe_te = $opt->get_poe_event;
sub POE::Kernel::TRACE_DEFAULT () { $poe_td }
sub POE::Kernel::TRACE_EVENTS () { $poe_te }
use Agent::TCLI::Transport::Test;
use Agent::TCLI::Testee;
use POE;
# TASK Test suite is not complete. Need testing for catching errors.
use_ok('Agent::TCLI::Package::Net::Ping');
my $test1 = Agent::TCLI::Package::Net::Ping->new({
'verbose' => \$verbose,
# 'do_verbose' => sub { diag( @_ ) },
});
my $test_master = Agent::TCLI::Transport::Test->new({
# 'peers' => \@users,
t/TCLI.Package.Net.SMTP.t view on Meta::CPAN
$poe_td = 0 unless defined($poe_td);
$poe_te = 0 unless defined($poe_te);
sub POE::Kernel::TRACE_DEFAULT () { $poe_td }
sub POE::Kernel::TRACE_EVENTS () { $poe_te }
use POE;
use Agent::TCLI::Transport::Test;
use Agent::TCLI::Testee;
# TASK Test suite is not complete. Need testing for catching errors.
use_ok('Agent::TCLI::Package::Net::SMTP');
my $testee = "smtp";
# Need to use the test-builder for diagnostic output instead of printing
# Using a ref to verbose to support dynamic changing of verbosity while running
my $test1 = Agent::TCLI::Package::Net::SMTP->new({
'verbose' => \$verbose,
'do_verbose' => sub { diag( @_ ) },
t/TCLI.Package.Net.Traceroute.t view on Meta::CPAN
$poe_td = $opt->get_poe_debug;
$poe_te = $opt->get_poe_event;
sub POE::Kernel::TRACE_DEFAULT () { $poe_td }
sub POE::Kernel::TRACE_EVENTS () { $poe_te }
use Agent::TCLI::Transport::Test;
use Agent::TCLI::Testee;
use POE;
# TASK Test suite is not complete. Need more testing for catching errors.
use_ok('Agent::TCLI::Package::Net::Traceroute');
my $test1 = Agent::TCLI::Package::Net::Traceroute->new({
'verbose' => \$verbose,
'do_verbose' => sub { diag( @_ ) },
});
my $test_master = Agent::TCLI::Transport::Test->new({