NAME

AnyEvent::Radius::Client - module to implement AnyEvent based RADIUS client

SYNOPSYS

use AnyEvent;
use AnyEvent::Radius::Client;

my $dict = AnyEvent::Radius::Client->load_dictionary('path-to-radius-dictionary');

sub read_reply_callback {
    # $h is HASH-REF {type, request_id, av_list, from, authenticator}
    my ($self, $h) = @_;
    ...
}

my $client = AnyEvent::Radius::Client->new(
                    ip => $ip,
                    port => $port,
                    on_read => \&read_reply_callback,
                    dictionary => $dict,
                    secret => $secret,
                );
$client->send_auth(AV_LIST1);
$client->send_auth(AV_LIST2);
...
$client->wait;

DESCRIPTION

The AnyEvent::Radius::Client module allows to send multiple RADIUS requests in non-blocking way, and then wait for responses.

CONSTRUCTOR

new ( ..options hash )
ip
port - where to connect
secret - RADIUS secret string for remote server
dictionary - optional, dictionary loaded by load_dictionary() method
read_timeout
write_timeout - network I/O timeouts (default is 5 second)
Callbacks:
on_read - called when reply received, arguments is hash-ref with {request_id, type, av_list, authenticator} keys
on_read_raw - called when reply received, raw data packet is provided as argument
on_read_timeout - timeout waiting for reply from server. Aborts the waiting state
on_write_timeout - timeout sending request
on_error - invalid packet received, or low-level socket error

METHODS

load_dictionary ($dictionary-file)

Class method to load dictionary - returns the object to be passed to constructor

send_packet ( $type, $av_list )

Builds RADIUS packet using Data::Radius::Packet and store it to outgoing queue. Returns request id. Note that it's not possible to schedule more than 255 requests - trying to add more will return undef

send_auth ($av_list)
send_acct ($av_list)
send_pod ($av_list)
send_coa ($av_list)

Helper methods to send RADIUS request of required type by send_request()

wait()

Blocks until all requests are received or read timeout reached

on_ready ( $cond_var )

Used to coordinate multiple clients instead of wait()

Example:

my $cv = AnyEvent->condvar;
$client1->on_ready($cv);
$client2->on_ready($cv);
$client3->on_ready($cv);
$cv->recv;

Will be blocked until all clients finish their queue.

SEE ALSO

Authen::Radius, AnyEvent::Radius::Server, Data::Radius

AUTHOR

Sergey Leschenko <sergle.ua at gmail.com>

PortaOne Development Team <perl-radius at portaone.com> is the current module's maintainer at CPAN.