NAME
AnyEvent::Ident::Server - Simple asynchronous ident server
VERSION
version 0.02
SYNOPSIS
use AnyEvent::Ident::Server;
my $server = AnyEvent::Ident::Server->new;
$server->start(sub {
my $tx = shift;
if($tx->req->server_port == 400
&& $tx->req->client_port == 500)
{
$tx->reply_with_user('UNIX', 'grimlock');
}
else
{
$tx->reply_with_error('NO-USER');
}
});
DESCRIPTION
Provide a simple asynchronous ident server.
CONSTRUCTOR
The constructor takes the following optional arguments:
hostname (default 127.0.0.1)
The hostname to connect to.
port (default 113)
The port to connect to.
on_error (carp error)
A callback subref to be called on error (either connection or transmission error). Passes the error string as the first argument to the callback.
$server->start( $callback )
Start the Ident server. The given callback will be called on each ident request (there may be multiple ident requests for each connection). The first and only argument passed to the callback is the transaction, an instance of AnyEvent::Ident::Transaction. The most important attribute on the transaction object are res
, the response object (itself an instance of AnyEvent::Ident::Transaction with server_port
and client_port
attributes) and the most important methods on the transaction object are reply_with_user
and reply_with_error
which reply with a successful and error response respectively.
$server->bindport
The bind port. If port is set to zero in the constructor or on start, then an ephemeral port will be used, and you can get the port number here.
$server->stop
Stop the server and unbind to the port.
AUTHOR
Graham Ollis <plicease@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2013 by Graham Ollis.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.