line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package AnyEvent::TLS::SNI; |
2
|
|
|
|
|
|
|
# ABSTRACT: adds Server Name Indication (SNI) support to AnyEvent::TLS client. |
3
|
|
|
|
|
|
|
$AnyEvent::TLS::SNI::VERSION = '0.01'; |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
30886
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
37
|
|
6
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
7
|
1
|
|
|
1
|
|
4
|
no warnings 'redefine'; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
31
|
|
8
|
1
|
|
|
1
|
|
4
|
no strict 'refs'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
53
|
|
9
|
1
|
|
|
1
|
|
508
|
use AnyEvent::TLS; |
|
1
|
|
|
|
|
10759
|
|
|
1
|
|
|
|
|
36
|
|
10
|
1
|
|
|
1
|
|
7
|
use Net::SSLeay; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
35
|
|
11
|
1
|
|
|
1
|
|
3
|
use Carp qw( croak ); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
183
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
croak 'Client side SNI not supported for this openssl' |
14
|
|
|
|
|
|
|
if Net::SSLeay::OPENSSL_VERSION_NUMBER() < 0x01000000; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
{ |
17
|
|
|
|
|
|
|
my $old_ref = \&{ 'AnyEvent::TLS::new' }; |
18
|
|
|
|
|
|
|
*{ 'AnyEvent::TLS::new' } = sub { |
19
|
2
|
|
|
2
|
|
381417
|
my ( $class, %param ) = @_; |
20
|
|
|
|
|
|
|
|
21
|
2
|
|
|
|
|
16
|
my $self = $old_ref->( $class, %param ); |
22
|
|
|
|
|
|
|
|
23
|
2
|
100
|
|
|
|
4880
|
$self->{host_name} = $param{host_name} |
24
|
|
|
|
|
|
|
if exists $param{host_name}; |
25
|
|
|
|
|
|
|
|
26
|
2
|
|
|
|
|
10
|
$self; |
27
|
|
|
|
|
|
|
}; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
{ |
31
|
|
|
|
|
|
|
my $old_ref = \&{ 'AnyEvent::TLS::_get_session' }; |
32
|
|
|
|
|
|
|
*{ 'AnyEvent::TLS::_get_session' } = sub($$;$$) { |
33
|
2
|
|
|
2
|
|
20
|
my ($self, $mode, $ref, $cn) = @_; |
34
|
|
|
|
|
|
|
|
35
|
2
|
|
|
|
|
11
|
my $session = $old_ref->( @_ ); |
36
|
|
|
|
|
|
|
|
37
|
2
|
50
|
|
|
|
234
|
if ( $mode eq 'connect' ) { |
38
|
2
|
100
|
|
|
|
7
|
if ( $self->{host_name} ) { |
39
|
1
|
|
|
|
|
7
|
Net::SSLeay::set_tlsext_host_name( $session, $self->{host_name} ); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
2
|
|
|
|
|
8
|
$session; |
44
|
|
|
|
|
|
|
}; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
__END__ |