Graham Ollis > AnyEvent-Ident-0.06 > AnyEvent::Ident::Server

Download:
AnyEvent-Ident-0.06.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 0.06   Source  

NAME ^

AnyEvent::Ident::Server - Simple asynchronous ident server

VERSION ^

version 0.06

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. This class manages connections and handles client errors for you, but you have to provide an implementation which determines the owner for a connection given a server and client port. This class may also be useful for testing ident clients against (see the test suite in this distribution, it uses this class to test AnyEvent::Ident::Client), or for constructing an ident server which always returns the same user (which may be useful for some applications, such as IRC).

CONSTRUCTOR ^

The constructor takes the following optional arguments:

$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.

syntax highlighting: