| 1 | package Lim::RPC::TLS; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 10 | ▶ | use common::sense; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 10 | ▶ | use Carp; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 10 | ▶ | use Log::Log4perl (); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 10 | ▶ | use AnyEvent::TLS (); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | 10 | ▶ | use Net::SSLeay (); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | 10 | ▶ | use Lim (); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | =encoding utf8 | ||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | =head1 NAME | ||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | ... | ||||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | =head1 VERSION | ||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | See L<Lim> for version. | ||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | =cut | ||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | 10 | our $VERSION = $Lim::VERSION; | |||||||||||||||||||
| 26 | 10 | our $INSTANCE; | |||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | =head1 SYNOPSIS | ||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | ... | ||||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | =head1 SUBROUTINES/METHODS | ||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | =head2 new | ||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | =cut | ||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | sub new { | ||||||||||||||||||||
| 39 | 0 | ▶ | my $this = shift; | ||||||||||||||||||
|
Subroutine
new: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||
| 40 | 0 | ▶ | my $class = ref($this) || $this; | ||||||||||||||||||
|
Condition0%0/3
ref $this || $this
MC/DC0%0/2
ref $this || $this
ref $this
$this
Truth table0%0/3
A || B
A= ref $thisB= $this
| |||||||||||||||||||||
| 41 | 0 | my $self = { | |||||||||||||||||||
| 42 | logger => Log::Log4perl->get_logger, | ||||||||||||||||||||
| 43 | }; | ||||||||||||||||||||
| 44 | 0 | bless $self, $class; | |||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | 0 | eval { | |||||||||||||||||||
| 47 | 0 | ▶ | if (!defined Lim::Config->{rpc}->{tls}->{key_file}) { | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 48 | 0 | $@ = 'No key_file set'; | |||||||||||||||||||
| 49 | } | ||||||||||||||||||||
| 50 | elsif (!defined Lim::Config->{rpc}->{tls}->{cert_file}) { | ||||||||||||||||||||
| 51 | 0 | $@ = 'No cert_file set'; | |||||||||||||||||||
| 52 | } | ||||||||||||||||||||
| 53 | else { | ||||||||||||||||||||
| 54 | 0 | $self->{tls_ctx} = AnyEvent::TLS->new(%{Lim::Config->{rpc}->{tls}}); | |||||||||||||||||||
| 55 | } | ||||||||||||||||||||
| 56 | }; | ||||||||||||||||||||
| 57 | 0 | ▶ | if ($@) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 58 | 0 | ▶ | Lim::OBJ_DEBUG and $self->{logger}->debug('Unable to initialize TLS context, will not use TLS/SSL: ', $@); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 59 | 0 | $self->{tls_ctx} = undef; | |||||||||||||||||||
| 60 | } | ||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | 0 | ▶ | Lim::OBJ_DEBUG and $self->{logger}->debug('new ', __PACKAGE__, ' ', $self); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 63 | 0 | $self; | |||||||||||||||||||
| 64 | } | ||||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | sub DESTROY { | ||||||||||||||||||||
| 67 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||
|
Subroutine
DESTROY: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 68 | 0 | ▶ | Lim::OBJ_DEBUG and $self->{logger}->debug('destroy ', __PACKAGE__, ' ', $self); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 69 | } | ||||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | END { | ||||||||||||||||||||
| 72 | 10 | ▶ | undef($INSTANCE); | ||||||||||||||||||
|
Subroutine
END: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 73 | } | ||||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | =head2 instance | ||||||||||||||||||||
| 76 | |||||||||||||||||||||
| 77 | =cut | ||||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | sub instance { | ||||||||||||||||||||
| 80 | 0 | ▶ | $INSTANCE ||= Lim::RPC::TLS->new; | ||||||||||||||||||
|
Subroutine
instance: not called CC=2 SCAR=17.9
Pod
documented
Condition0%0/3
$Lim::RPC::TLS::INSTANCE ||= "Lim::RPC::TLS"->new
MC/DC0%0/2
$Lim::RPC::TLS::INSTANCE ||= "Lim::RPC::TLS"->new
$Lim::RPC::TLS::INSTANCE
"Lim::RPC::TLS"->new
Truth table0%0/3
A ||= B
A= $Lim::RPC::TLS::INSTANCEB= "Lim::RPC::TLS"->new
| |||||||||||||||||||||
| 81 | } | ||||||||||||||||||||
| 82 | |||||||||||||||||||||
| 83 | =head2 tls_ctx | ||||||||||||||||||||
| 84 | |||||||||||||||||||||
| 85 | =cut | ||||||||||||||||||||
| 86 | |||||||||||||||||||||
| 87 | sub tls_ctx { | ||||||||||||||||||||
| 88 | 0 | ▶ | $_[0]->{tls_ctx}; | ||||||||||||||||||
|
Subroutine
tls_ctx: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 89 | } | ||||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | =head1 AUTHOR | ||||||||||||||||||||
| 92 | |||||||||||||||||||||
| 93 | Jerry Lundström, C<< <lundstrom.jerry at gmail.com> >> | ||||||||||||||||||||
| 94 | |||||||||||||||||||||
| 95 | =head1 BUGS | ||||||||||||||||||||
| 96 | |||||||||||||||||||||
| 97 | Please report any bugs or feature requests to L<https://github.com/jelu/lim/issues>. | ||||||||||||||||||||
| 98 | |||||||||||||||||||||
| 99 | =head1 SUPPORT | ||||||||||||||||||||
| 100 | |||||||||||||||||||||
| 101 | You can find documentation for this module with the perldoc command. | ||||||||||||||||||||
| 102 | |||||||||||||||||||||
| 103 | perldoc Lim | ||||||||||||||||||||
| 104 | |||||||||||||||||||||
| 105 | You can also look for information at: | ||||||||||||||||||||
| 106 | |||||||||||||||||||||
| 107 | =over 4 | ||||||||||||||||||||
| 108 | |||||||||||||||||||||
| 109 | =item * Lim issue tracker (report bugs here) | ||||||||||||||||||||
| 110 | |||||||||||||||||||||
| 111 | L<https://github.com/jelu/lim/issues> | ||||||||||||||||||||
| 112 | |||||||||||||||||||||
| 113 | =back | ||||||||||||||||||||
| 114 | |||||||||||||||||||||
| 115 | =head1 ACKNOWLEDGEMENTS | ||||||||||||||||||||
| 116 | |||||||||||||||||||||
| 117 | =head1 LICENSE AND COPYRIGHT | ||||||||||||||||||||
| 118 | |||||||||||||||||||||
| 119 | Copyright 2012-2013 Jerry Lundström. | ||||||||||||||||||||
| 120 | |||||||||||||||||||||
| 121 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||
| 122 | under the terms of either: the GNU General Public License as published | ||||||||||||||||||||
| 123 | by the Free Software Foundation; or the Artistic License. | ||||||||||||||||||||
| 124 | |||||||||||||||||||||
| 125 | See http://dev.perl.org/licenses/ for more information. | ||||||||||||||||||||
| 126 | |||||||||||||||||||||
| 127 | |||||||||||||||||||||
| 128 | =cut | ||||||||||||||||||||
| 129 | |||||||||||||||||||||
| 130 | 10 | 1; # End of Lim::RPC::TLS | |||||||||||||||||||