Jabber-Lite
view release on metacpan or search on metacpan
IO::Socket::INET
IO::Select
Soft Dependencies:
Net::DNS
Digest::SHA1
Authen::SASL
MIME::Base64
IO::Socket::SSL
Scalar::Util
lib/Jabber/Lite.pm view on Meta::CPAN
=item UseSSL
Initiate a SSL/TLS connection immediately on connecting, for example, if
you are connecting to a server which offers SSL on an alternative port.
Defaults to 0. This is used internally to redo the connection.
=item UseTLS
Negotiate a TLS connection if <starttls> is listed as one of the connection
features, and IO::Socket::SSL is available. Defaults to 1, as everyone likes
encryption.
=item MustEncrypt
The connection must be encrypted before considering the connection to be
opened. This defaults to 0. If this is set to 1, and IO::Socket::SSL is not
available, the connection will fail.
=item JustConnect
This simply opens a connection and returns without having sent any packets,
except for any required to initiate SSL if requested. The calling program
is responsible for sending any initial packets down the link, and
responding to any packets received. Defaults to 0.
=item JustConnectAndStream
lib/Jabber/Lite.pm view on Meta::CPAN
Note that during the SSL negotiation, the application will block, due to
the perl SSL libraries not obviously supporting a backgroundable method.
=item Version
The version to declare to the remote Jabber server. The default, '1.0',
attempts to steer the conversation along the lines of RFC3920, xmpp-core.
=item SSL*
Any option beginning with 'SSL' will be passed to IO::Socket::SSL as-is,
which may be useful if you are expecting to exchange certificate
information. No values are set up by default.
=item OwnSocket
A boolean which indicates that a socket has previously been created by
methods unknown to this library, and stored via ->socket(). Thus,
->connect doesn't actually have to do a TCP connection, and can just
continue on with the connection methods.
lib/Jabber/Lite.pm view on Meta::CPAN
if( $cango ){
# Start up SSL or TLS as required.
# Has SSL been requested?
if( ( $args{"UseSSL"} || $args{"MustEncrypt"} ) && ! $self->_check_val( '_is_encrypted') ){
# Start SSL.
my $gotssl = $self->_got_IO_Socket_SSL();
if( $gotssl ){
# We have to hand over the socket to the
# IO::Socket::SSL library for conversion.
$gotssl = 0;
my %SSLHash = ();
foreach my $kkey( keys %args ){
next unless( $kkey =~ /^SSL/ );
$SSLHash{"$kkey"} = $args{"$kkey"};
}
$self->debug( "connect: Starting up SSL\n" );
my $newsock = IO::Socket::SSL->start_SSL( $self->socket,
%SSLHash,
);
if( defined( $newsock ) ){
$self->socket( $newsock );
$gotssl = 1;
$self->{'_is_encrypted'} = 1;
$self->debug( "connect: Successfully started SSL\n" ) ;
}else{
$self->debug( "connect: Could not start SSL\n" );
}
lib/Jabber/Lite.pm view on Meta::CPAN
$retval = -1;
my $nwritable = $self->can_write();
# Is the socket still connected? can_write() does not
# detect this condition.
my $amconnected = 0;
if( defined( $self->socket->connected ) ){
$amconnected = 1;
}
# IO::Socket::SSL does not have send; I missed this when
# changed from syswrite.
my $usesend = 1;
if( ! defined( $self->{'_checked_send_ability'} ) ){
my $tsock = $self->socket();
my $tref = ref( $tsock );
if( $tref =~ /SSL/ ){
# Does it have send?
if( $amconnected && $nwritable ){
eval {
lib/Jabber/Lite.pm view on Meta::CPAN
$self->debug( "aborting!\n" );
# print STDERR "ABORTING!\n";
if( defined( $self->socket() ) ){
if( defined( $self->{'_select'} ) ){
$self->{'_select'}->remove( $self->socket() );
}
my $tref = ref( $self->socket );
if( $tref ){
if( $tref =~ /SSL/ ){
# IO::Socket::SSL says that it has the
# possibility of blocking unless the
# SSL_no_shutdown argument is specified.
# Some servers may not like this behaviour.
$self->socket->close( SSL_no_shutdown => 1 );
}else{
close( $self->socket() );
}
delete( $self->{'_checked_send_ability'} );
}else{
close( $self->socket() );
lib/Jabber/Lite.pm view on Meta::CPAN
require MIME::Base64;
$retval++;
};
$self->debug( " returning $retval\n" );
return( $retval );
}
=head2 _got_IO_Socket_SSL
Helper function to load IO::Socket::SSL into the current namespace.
=cut
sub _got_IO_Socket_SSL {
my $self = shift;
my $retval = 0;
eval {
require IO::Socket::SSL;
$retval++;
};
$self->debug( " returning $retval\n" );
return( $retval );
}
=head2 debug
Debug is vor finding de bugs!
lib/Jabber/Lite.pm view on Meta::CPAN
circular dependencies.
=head1 PREREQUISITES / DEPENDENCIES
IO::Socket::INET, IO::Select . Thats it. Although, if you want encryption
on your connection, SASL support or reasonable garbage collection in various
versions of perl, there are soft dependencies on:
=over 4
=item IO::Socket::SSL
Library for handling SSL/TLS encryption.
=item MIME::Base64
This is used for some authentication methods.
=item Authen::SASL
SASL magic. Hooray.
( run in 0.315 second using v1.01-cache-2.11-cpan-fd5d4e115d8 )