blib/lib/POE/Component/SSLify/ClientHandle.pm

filter: Statementstmt 100% 24 / 24 Branchbran 50.0% 3 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 91.4% 32 / 35 SCAR 13.9
CC
4
Cov
90%
TIEHANDLE
4.1
BEGIN
1.0
BEGIN
1.0
CRAP 4.0
« blib/lib/POE/Component/SSLify/ServerHandle.pm ↑ Summary Build »
1 #
2 # This file is part of POE-Component-SSLify
3 #
4 # This software is copyright (c) 2014 by Apocalypse.
5 #
6 # This is free software; you can redistribute it and/or modify it under
7 # the same terms as the Perl 5 programming language system itself.
8 #
9 15 ▶use strict; use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
10 package POE::Component::SSLify::ClientHandle;
11 15 $POE::Component::SSLify::ClientHandle::VERSION = '1.010';
12 15 our $AUTHORITY = 'cpan:APOCAL';
13  
14 # ABSTRACT: Client-side handle for SSLify
15  
16 # Import the SSL death routines
17 15 ▶use Net::SSLeay 1.36 qw( die_now die_if_ssl_error );
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 # We inherit from ServerHandle
20 15 ▶use parent 'POE::Component::SSLify::ServerHandle';
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 # Override TIEHANDLE because we create a CTX
23 sub TIEHANDLE {
24 28 ▶ my ( $class, $socket, $version, $options, $ctx, $connref ) = @_;
Subroutine TIEHANDLE: called CC=4 SCAR=14.2
25  
26 # create a context, if necessary
27 28 ▶ if ( ! defined $ctx ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $ctx) 28 0 28
28 28 $ctx = POE::Component::SSLify::_createSSLcontext( undef, undef, $version, $options );
29 }
30  
31 28 ▶ my $ssl = Net::SSLeay::new( $ctx ) or die_now( "Failed to create SSL $!" );
Branch: 1 branch
BranchTrueFalseTotal
my $ssl = &Net::SSLeay::new($ctx) or die_now("Failed to create SSL $!") 0 28 28
32  
33 28 my $fileno = fileno( $socket );
34  
35 28 Net::SSLeay::set_fd( $ssl, $fileno ); # Must use fileno
36  
37 # Socket is in non-blocking mode, so connect() will return immediately.
38 # die_if_ssl_error won't die on non-blocking errors. We don't need to call connect()
39 # again, because OpenSSL I/O functions (read, write, ...) can handle that entirely
40 # by self (it's needed to connect() once to determine connection type).
41 28 ▶ my $res = Net::SSLeay::connect( $ssl ) or die_if_ssl_error( 'ssl connect' );
Branch: 1 branch
BranchTrueFalseTotal
my $res = &Net::SSLeay::connect($ssl) or die_if_ssl_error("ssl connect") 0 28 28
42  
43 28 my $self = bless {
44 'ssl' => $ssl,
45 'ctx' => $ctx,
46 'socket' => $socket,
47 'fileno' => $fileno,
48 'client' => 1,
49 'status' => $res,
50 'on_connect' => $connref,
51 }, $class;
52  
53 28 return $self;
54 }
55  
56 15 1;
57  
58 __END__
« blib/lib/POE/Component/SSLify/ServerHandle.pm ↑ Summary Build »