line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package POE::Component::TLSify; |
2
|
|
|
|
|
|
|
$POE::Component::TLSify::VERSION = '0.06'; |
3
|
|
|
|
|
|
|
#ABSTRACT: Makes using SSL/TLS in the world of POE easy! |
4
|
|
|
|
|
|
|
|
5
|
11
|
|
|
11
|
|
1831118
|
use strict; |
|
11
|
|
|
|
|
97
|
|
|
11
|
|
|
|
|
282
|
|
6
|
11
|
|
|
11
|
|
50
|
use warnings; |
|
11
|
|
|
|
|
19
|
|
|
11
|
|
|
|
|
355
|
|
7
|
|
|
|
|
|
|
|
8
|
11
|
|
|
11
|
|
55
|
use Symbol qw[gensym]; |
|
11
|
|
|
|
|
18
|
|
|
11
|
|
|
|
|
465
|
|
9
|
11
|
|
|
11
|
|
64
|
use Scalar::Util qw[weaken]; |
|
11
|
|
|
|
|
27
|
|
|
11
|
|
|
|
|
500
|
|
10
|
11
|
|
|
11
|
|
4228
|
use POE::Component::TLSify::ClientHandle; |
|
11
|
|
|
|
|
32
|
|
|
11
|
|
|
|
|
386
|
|
11
|
11
|
|
|
11
|
|
64
|
use POE::Component::TLSify::ServerHandle; |
|
11
|
|
|
|
|
19
|
|
|
11
|
|
|
|
|
221
|
|
12
|
|
|
|
|
|
|
|
13
|
11
|
|
|
11
|
|
42
|
use parent 'Exporter'; |
|
11
|
|
|
|
|
19
|
|
|
11
|
|
|
|
|
46
|
|
14
|
|
|
|
|
|
|
our @EXPORT_OK = qw[ |
15
|
|
|
|
|
|
|
Client_TLSify Server_TLSify TLSify_GetSocket TLSify_GetCipher |
16
|
|
|
|
|
|
|
]; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub Server_TLSify { |
19
|
18
|
|
|
18
|
1
|
71639
|
my ($socket,$args,$callback) = @_; |
20
|
|
|
|
|
|
|
|
21
|
18
|
50
|
|
|
|
59
|
if ( ! defined $socket ) { |
22
|
0
|
|
|
|
|
0
|
die 'Did not get a defined socket'; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
18
|
50
|
|
|
|
197
|
if ( ! defined $socket->blocking( 0 ) ) { |
26
|
0
|
|
|
|
|
0
|
die "Unable to set nonblocking mode on socket: $!"; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
18
|
50
|
66
|
|
|
98
|
if ( defined $callback && ref $callback ne 'CODE' ) { |
30
|
0
|
|
|
|
|
0
|
undef $callback; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
18
|
|
|
|
|
60
|
my $newsock = gensym(); |
34
|
18
|
50
|
|
|
|
409
|
tie( *$newsock, 'POE::Component::TLSify::ServerHandle', $socket, $args, $callback ) or die "Unable to tie to our subclass: $!"; |
35
|
|
|
|
|
|
|
|
36
|
18
|
100
|
|
|
|
51
|
if ( defined $callback ) { |
37
|
4
|
|
|
|
|
11
|
tied( *$newsock )->{'orig_socket'} = $newsock; |
38
|
4
|
|
|
|
|
16
|
weaken ( tied( *$newsock )->{'orig_socket'} ); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
18
|
|
|
|
|
50
|
return $newsock; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub Client_TLSify { |
45
|
18
|
|
|
18
|
1
|
14432
|
my ($socket,$args,$callback) = @_; |
46
|
|
|
|
|
|
|
|
47
|
18
|
50
|
|
|
|
55
|
if ( ! defined $socket ) { |
48
|
0
|
|
|
|
|
0
|
die 'Did not get a defined socket'; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
18
|
50
|
|
|
|
154
|
if ( ! defined $socket->blocking( 0 ) ) { |
52
|
0
|
|
|
|
|
0
|
die "Unable to set nonblocking mode on socket: $!"; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
18
|
50
|
66
|
|
|
94
|
if ( defined $callback && ref $callback ne 'CODE' ) { |
56
|
0
|
|
|
|
|
0
|
undef $callback; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
18
|
|
|
|
|
62
|
my $newsock = gensym(); |
60
|
18
|
50
|
|
|
|
380
|
tie( *$newsock, 'POE::Component::TLSify::ClientHandle', $socket, $args, $callback ) or die "Unable to tie to our subclass: $!"; |
61
|
|
|
|
|
|
|
|
62
|
18
|
100
|
|
|
|
65
|
if ( defined $callback ) { |
63
|
4
|
|
|
|
|
15
|
tied( *$newsock )->{'orig_socket'} = $newsock; |
64
|
4
|
|
|
|
|
14
|
weaken ( tied( *$newsock )->{'orig_socket'} ); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
18
|
|
|
|
|
49
|
return $newsock; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub TLSify_GetSocket { |
71
|
30
|
|
|
30
|
1
|
8070
|
my $sock = shift; |
72
|
30
|
|
|
|
|
167
|
return tied( *$sock )->{'socket'}; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub TLSify_GetCipher { |
76
|
62
|
|
|
62
|
1
|
30604
|
my $sock = shift; |
77
|
62
|
|
|
|
|
266
|
return tied( *$sock )->{'socket'}->get_cipher; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
qq[I TLSify!]; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
__END__ |