Event-RPC

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

      fixes missing encoding declarations in POD. Thanks!
    - Fixed some POD typos. Thanks for the report to
      Xavier Guimard.

1.04 Fri Feb 24, 2014, joern
    Bugfixes
    - Under certain infrequently conditions it could
      happen that the server process blocked when
      sending a response packet to a client.
    - Event::RPC::Client failed loading when no
      IO::Socket::SSL is installed.

1.03 Sat Feb  2, 2013, joern
    Features:
    - Added options 'ssl_ca_file and 'ssl_ca_path' options
      to Event::RPC::Client, which enable SSL peer verifcation
      on the client. Thanks for the report about a security
      warning of IO::Socket::SSL to Moritz Bunkus.

1.02 Tue Mar  8, 2011, joern
    Features:
    - Added AnyEvent mainloop implementation.

1.01 Sat Oct 25, 2008, joern
    Bugfixes:
    - Even objects returned by methods not declared as
      an "object returner" where turned into Event::RPC
      object handles instead of copying the complete

Changes  view on Meta::CPAN

0.86 Sat Dec 17, 2005, joern
    Features:
    - added Event::RPC::Server->get_active_connection
    - documented Event::RPC::Connection->get_client_oids
    - added Event::RPC::Connection->get_client_object

    Bugfixes:
    - Added missing documentation for Event::RPC::Client's
      error_cb attribute, which was just mentioned in
      the SYNPOSIS.
    - Fixed an incompatability with IO::Socket::SSL 0.97,
      which doesn't return different sysread() states for
      error and eof anymore which confused Event::RPC.

0.85 Sun Aug 28, 2005, joern
    Bugfixes:
    - Make server more bullet proof: handle log connections
      even if no logger is set, but a log listener was started.
    - Event::RPC::Server->new didn't recognize the
      'connection_hook' parameter.
    - Try making the testsuite more stable with Win32.

Changes  view on Meta::CPAN

    - Full documentation added.
    - Test suite added which covers all connection
      types and the most important features.

0.81 Sun Mar 13, 2005, joern
    Notes:
    - Still an internal release, incomplete documentation, no
      test suite.

    Features:
    - Support for SSL encryption added using IO::Socket::SSL.
    - Event loop abstraction. Event::RPC now works with Event
      and Glib and can be easily extended for other event loop
      frameworks. Thanks to Rocco Caputo for the suggestion.

0.80 Sun Mar 13, 2005, joern
    Notes:
    - A non public release. Only announced on the perl-loop mailing
      list for the namespace request and to get comments. Module
      is fully working but API isn't documented yet very well.
      Security stuff (SSL encryption, some password authentication)

META.json  view on Meta::CPAN

      "configure" : {
         "requires" : {
            "ExtUtils::MakeMaker" : "0"
         }
      },
      "runtime" : {
         "requires" : {
            "Event" : "0",
            "Glib" : "0",
            "IO::Socket::INET" : "0",
            "IO::Socket::SSL" : "0",
            "JSON::XS" : "3",
            "Net::SSLeay" : "0",
            "Sereal" : "3",
            "Storable" : "0",
            "Test::More" : "0"
         }
      }
   },
   "release_status" : "stable",
   "version" : "1.10",

META.yml  view on Meta::CPAN

  version: '1.4'
name: Event-RPC
no_index:
  directory:
    - t
    - inc
requires:
  Event: '0'
  Glib: '0'
  IO::Socket::INET: '0'
  IO::Socket::SSL: '0'
  JSON::XS: '3'
  Net::SSLeay: '0'
  Sereal: '3'
  Storable: '0'
  Test::More: '0'
version: '1.10'
x_serialization_backend: 'CPAN::Meta::YAML version 0.018'

Makefile.PL  view on Meta::CPAN


if ( !$format_modules ) {
    print "\n";
    print "*****************************************************************\n";
    print "WARNING: You need Sereal, CBOR::XS, JSON::XS or Storable module\n";
    print "*****************************************************************\n";
    print "\n";
}

my $has_ssl;
eval { require IO::Socket::SSL; $has_ssl = 1 } || do {
    print "\n";
    print "NOTE: Event::RPC is capable of SSL encrypted connections,\n";
    print "      but your Perl is missing the IO::Socket::SSL module.\n";
    print "      Event::RPC works perfectly without the module, but you\n";
    print "      can't use SSL connections until IO::Socket::SSL is\n";
    print "      installed.\n";
    print "\n";
};

#-- Add found modules to PREREQ_PM, so CPAN Testers add
#-- version numbers of these modules to the reports, which
#-- are very important in case of failing tests.
my @add_prereq;
push @add_prereq, 'AnyEvent', 0        if not $loop_modules;
push @add_prereq, 'Event', 0           if $has_event;
push @add_prereq, 'Glib', 0            if $has_glib;

push @add_prereq, "Sereal", 3.0        if $has_sereal or not $format_modules;
push @add_prereq, "CBOR::XS", 0        if $has_cbor_xs;
push @add_prereq, "JSON::XS", 3.0      if $has_json_xs;
push @add_prereq, "Storable", 0        if $has_storable;

push @add_prereq, 'IO::Socket::SSL', 0 if $has_ssl;
push @add_prereq, 'Net::SSLeay', 0     if $has_ssl;

WriteMakefile(
    'NAME'	   => 'Event::RPC',
    'VERSION_FROM' => 'lib/Event/RPC.pm',
    'PREREQ_PM'    => {
    	'Test::More'       => 0,
        'Storable'         => 0,
        'IO::Socket::INET' => 0,
        @add_prereq,

README  view on Meta::CPAN

      $client->connect;

      #-- Call methods of My::TestModule on the server
      my $obj = My::TestModule->new ( foo => "bar" );
      my $foo = $obj->get_foo;

ABSTRACT
    Event::RPC supports you in developing Event based networking
    client/server applications with transparent object/method access from
    the client to the server. Network communication is optionally encrypted
    using IO::Socket::SSL. Several event loop managers are supported due to
    an extensible API. Currently Event, Glib and AnyEvent are implemented.
    The latter lets you use nearly every event loop implementation available
    for Perl. AnyEvent was invented after Event::RPC was created and thus
    Event::RPC started using it's own abstraction model.

DESCRIPTION
    Event::RPC consists of a server and a client library. The server exports
    a list of classes and methods, which are allowed to be called over the
    network. More specific it acts as a proxy for objects created on the
    server side (on demand of the connected clients) which handles client

README  view on Meta::CPAN

    Event::RPC needs either one of the following modules on the server
    (they're not necessary on the client):

      Event
      Glib
      AnyEvent

    They're needed for event handling resp. mainloop implementation. If you
    like to use SSL encryption you need to install

      IO::Socket::SSL

    Event::RPC needs minimum one of the following modules for data
    serialisation:

      Sereal (::Decoder and ::Encoder)
      CBOR::XS
      JSON::XS
      Storable

    Server and client negotiate automatically which serialiser to use to

lib/Event/RPC.pm  view on Meta::CPAN

      port     => 5555,
  );
  $client->connect;

  #-- Call methods of My::TestModule on the server
  my $obj = My::TestModule->new ( foo => "bar" );
  my $foo = $obj->get_foo;

=head1 ABSTRACT

Event::RPC supports you in developing Event based networking client/server applications with transparent object/method access from the client to the server. Network communication is optionally encrypted using IO::Socket::SSL. Several event loop manag...

=head1 DESCRIPTION

Event::RPC consists of a server and a client library. The server exports a list of classes and methods, which are allowed to be called over the network. More specific it acts as a proxy for objects created on the server side (on demand of the connect...

The object proxy handles refcounting and destruction of objects created by clients properly. Objects as method parameters and return values are handled as well (although with some limitations, see below).

For the client the whole thing is totally transparent - once connected to the server it doesn't know whether it calls methods on local or remote objects.

Also the methods on the server newer know whether they are called locally

lib/Event/RPC.pm  view on Meta::CPAN

Event::RPC needs either one of the following modules on the server
(they're not necessary on the client):

  Event
  Glib
  AnyEvent

They're needed for event handling resp. mainloop implementation.
If you like to use SSL encryption you need to install

  IO::Socket::SSL

Event::RPC needs minimum one of the following modules for
data serialisation:

  Sereal (::Decoder and ::Encoder)
  CBOR::XS
  JSON::XS
  Storable

Server and client negotiate automatically which serialiser to use

lib/Event/RPC/Client.pm  view on Meta::CPAN

    my $timeout = $self->get_timeout;

    $self->set_message_format($Event::RPC::Client::DEFAULT_MESSAGE_FORMAT);

    #-- Client may try to fallback to Storable
    Event::RPC::Message::Negotiate->set_storable_fallback_ok(1)
        if $self->get_message_format eq 'Event::RPC::Message::Negotiate' and
           $self->get_insecure_msg_fmt_ok;

    if ( $ssl ) {
        eval { require IO::Socket::SSL };
        croak "SSL requested, but IO::Socket::SSL not installed" if $@;
    }

    my $sock;
    if ( $ssl ) {
        my @verify_opts;
        if ( $self->get_ssl_ca_file or $self->get_ssl_ca_path ) {
            push @verify_opts, (
                SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_PEER(),
                SSL_ca_file     => $self->get_ssl_ca_file,
                SSL_ca_path     => $self->get_ssl_ca_path,
            );
        }
        else {
            push @verify_opts, (
                SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE(),
            );
        }

        my $ssl_opts = $self->get_ssl_opts;

        $sock = IO::Socket::SSL->new(
            Proto    => 'tcp',
            PeerPort => $port,
            PeerAddr => $server,
            Type     => SOCK_STREAM,
            Timeout  => $timeout,
            @verify_opts,
            ($ssl_opts?%{$ssl_opts}:()),
        )
        or croak "Can't open SSL connection to $server:$port: $IO::Socket::SSL::ERROR";
    }
    else {
        $sock = IO::Socket::INET->new(
            Proto    => 'tcp',
            PeerPort => $port,
            PeerAddr => $server,
            Type     => SOCK_STREAM,
            Timeout  => $timeout,
        )
        or croak "Can't open connection to $server:$port - $!";

lib/Event/RPC/Client.pm  view on Meta::CPAN


=item B<ssl_ca_path>

Path of a directory containing several trusted certificates with
a proper index. Please refer to the OpenSSL documentation for
details about setting up such a directory.

=item B<ssl_opts>

This optional parameter takes a hash reference of options
passed to IO::Socket::SSL->new(...) to have more control
over the SSL connection. For example you can set the
'SSL_verifycn_name' here if the server certificate common
name doesn't match to the hostname you use to resolve
the server IP or use you have to use a static server IP
address or something like that. 

=back

=head2 AUTHENTICATION OPTIONS

lib/Event/RPC/Server.pm  view on Meta::CPAN

    my $port      = $self->get_port;
    my @LocalHost = $host ? ( LocalHost => $host ) : ();
    $host ||= "*";

    #-- get event loop manager
    my $loop = $self->get_loop;

    #-- setup rpc listener
    my $rpc_socket;
    if ( $self->get_ssl ) {
        eval { require IO::Socket::SSL };
        croak "SSL requested, but IO::Socket::SSL not installed" if $@;
        croak "ssl_key_file not set"  unless $self->get_ssl_key_file;
        croak "ssl_cert_file not set" unless $self->get_ssl_cert_file;

        my $ssl_opts = $self->get_ssl_opts;

        $rpc_socket = IO::Socket::SSL->new (
            Listen          => SOMAXCONN,
            @LocalHost,
            LocalPort       => $port,
            Proto           => 'tcp',
            ReuseAddr       => 1,
            SSL_key_file    => $self->get_ssl_key_file,
            SSL_cert_file   => $self->get_ssl_cert_file,
            SSL_passwd_cb   => $self->get_ssl_passwd_cb,
            ($ssl_opts?%{$ssl_opts}:()),
        ) or die "can't start SSL RPC listener: $IO::Socket::SSL::ERROR";
    }
    else {
        $rpc_socket = IO::Socket::INET->new (
            Listen    => SOMAXCONN,
            @LocalHost,
            LocalPort => $port,
            Proto     => 'tcp',
            ReuseAddr => 1,
        ) or die "can't start RPC listener: $!";
    }

lib/Event/RPC/Server.pm  view on Meta::CPAN


=back

=back

=head2 SSL OPTIONS

The client/server protocol of Event::RPC is not encrypted by default,
so everyone listening on your network can read or even manipulate
data. To prevent this efficiently you can enable SSL encryption.
Event::RPC uses the IO::Socket::SSL Perl module for this.

First you need to generate a server key and certificate for your server
using the openssl command which is part of the OpenSSL distribution,
e.g. by issueing these commands (please refer to the manpage of openssl
for details - this is a very rough example, which works in general, but
probably you want to tweak some parameters):

  % openssl genrsa -des3 -out server.key 1024
  % openssl req -new -key server.key -out server.csr
  % openssl x509 -req -days 3600 -in server.csr \

lib/Event/RPC/Server.pm  view on Meta::CPAN

password, e.g.

  ssl_passwd_cb => sub { return "topsecret" }

But note: having the password in plaintext in your program code is
insecure!

=item B<ssl_opts>

This optional parameter takes a hash reference of options
passed to IO::Socket::SSL->new(...) to have more control
over the server SSL listener. 

=back

=head2 AUTHENTICATION OPTIONS

SSL encryption is fine, now it's really hard for an attacker to
listen or modify your network communication. But without any further
configuration any user on your network is able to connect to your
server. To prevent this users resp. connections to your server

t/04.cnct-auth-ssl-verifypeer-noca.t  view on Meta::CPAN

my $depend_modules = 0;
eval { require EV };
eval { require AnyEvent } && ++$depend_modules;
eval { require Event    } && ++$depend_modules;
eval { require Glib     } && ++$depend_modules;

if ( not $depend_modules ) {
    plan skip_all => "Neither AnyEvent, Event nor Glib installed";
}

eval { require IO::Socket::SSL };
if ( $@ ) {
	plan skip_all => "IO::Socket::SSL required";
}

plan tests => 4;

require "./t/Event_RPC_Test_Server.pm";
my $PORT = Event_RPC_Test_Server->port;

my $AUTH_USER = "foo";
my $AUTH_PASS = "bar";

t/04.cnct-auth-ssl-verifypeer-wrongca.t  view on Meta::CPAN

my $depend_modules = 0;
eval { require EV };
eval { require AnyEvent } && ++$depend_modules;
eval { require Event    } && ++$depend_modules;
eval { require Glib     } && ++$depend_modules;

if ( not $depend_modules ) {
    plan skip_all => "Neither AnyEvent, Event nor Glib installed";
}

eval { require IO::Socket::SSL };
if ( $@ ) {
	plan skip_all => "IO::Socket::SSL required";
}

plan tests => 5;

require "./t/Event_RPC_Test_Server.pm";
my $PORT = Event_RPC_Test_Server->port;

my $AUTH_USER = "foo";
my $AUTH_PASS = "bar";

t/04.cnct-auth-ssl-verifypeer.t  view on Meta::CPAN

my $depend_modules = 0;
eval { require EV };
eval { require AnyEvent } && ++$depend_modules;
eval { require Event    } && ++$depend_modules;
eval { require Glib     } && ++$depend_modules;

if ( not $depend_modules ) {
    plan skip_all => "Neither AnyEvent, Event nor Glib installed";
}

eval { require IO::Socket::SSL };
if ( $@ ) {
	plan skip_all => "IO::Socket::SSL required";
}

plan tests => 6;

require "./t/Event_RPC_Test_Server.pm";
my $PORT = Event_RPC_Test_Server->port;

my $AUTH_USER = "foo";
my $AUTH_PASS = "bar";

t/04.cnct-auth-ssl.t  view on Meta::CPAN

my $depend_modules = 0;
eval { require EV };
eval { require AnyEvent } && ++$depend_modules;
eval { require Event    } && ++$depend_modules;
eval { require Glib     } && ++$depend_modules;

if ( not $depend_modules ) {
    plan skip_all => "Neither AnyEvent, Event nor Glib installed";
}

eval { require IO::Socket::SSL };
if ( $@ ) {
	plan skip_all => "IO::Socket::SSL required";
}

plan tests => 6;

require "./t/Event_RPC_Test_Server.pm";
my $PORT = Event_RPC_Test_Server->port;

my $AUTH_USER = "foo";
my $AUTH_PASS = "bar";



( run in 0.434 second using v1.01-cache-2.11-cpan-fd5d4e115d8 )