MtPolicyd/Plugin/Proxy.pm

filter: Statementstmt 67.6% 23 / 34 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 71.4% 5 / 7 Podpod 100% 1 / 1 totaltotal 63.0% 29 / 46 CC 3 SCAR 15.6
CC
3
Cov
61%
__ANON__
12.0
run
2.0
BEGIN
1.0
CRAP 4.8
« MtPolicyd/Plugin/Fail2Ban.pm ↑ Summary MtPolicyd/PluginChain.pm »
1 package Mail::MtPolicyd::Plugin::Proxy;
2  
3 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 our $VERSION = '1.12'; # VERSION
7 # ABSTRACT: mtpolicyd plugin to forward request to another policy daemon
8  
9  
10 1 extends 'Mail::MtPolicyd::Plugin';
11  
12 1 ▶use Mail::MtPolicyd::Plugin::Result;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 ▶use Mail::MtPolicyd::Client;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use Mail::MtPolicyd::Client::Request;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 1 has 'socket_path' => ( is => 'rw', isa => 'Maybe[Str]' );
18 1 has 'host' => ( is => 'rw', isa => 'Maybe[Str]' );
19 1 has 'keepalive' => ( is => 'rw', isa => 'Bool', default => 0 );
20  
21 has _client => (
22 is => 'ro', isa => 'Mail::MtPolicyd::Client', lazy => 1,
23 default => sub {
24 0 ▶ my $self = shift;
Subroutine __ANON__: not called CC=3 SCAR=24.8
25 0 my %opts = (
26 keepalive => $self->keepalive,
27 );
28 0 ▶ if( defined $self->socket_path ) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $self->socket_path) { } 0 0 0
elsif (defined $self->host) { } 0 0 0
29 0 $opts{'socket_path'} = $self->socket_path;
30 } elsif( defined $self->host ) {
31 0 $opts{'host'} = $self->host;
32 } else {
33 0 $self->logdie('no host and no socket_path configured!');
34 }
35 0 return Mail::MtPolicyd::Client->new( %opts );
36 },
37 1 );
38  
39 sub run {
40 0 ▶ my ( $self, $r ) = @_;
Subroutine run: not called CC=1 SCAR=6.9
Pod documented
41  
42 0 my $proxy_request = Mail::MtPolicyd::Client::Request->new_proxy_request( $r );
43 0 my $response = $self->_client->request( $proxy_request );
44  
45 0 return Mail::MtPolicyd::Plugin::Result->new(
46 action => $response->action,
47 abort => 1,
48 );
49 }
50  
51 1 __PACKAGE__->meta->make_immutable;
52  
53 1 1;
54  
55  
56 __END__
57 =pod
58  
59 =head1 NAME
60  
61 Mail::MtPolicyd::Plugin::Proxy - mtpolicyd plugin to forward request to another policy daemon
62  
63 =head1 VERSION
64  
65 version 1.12
66  
67 =head1 DESCRIPTION
68  
69 This module forwards the request to another policy daemon.
70  
71 =head1 PARAMETERS
72  
73 =over
74  
75 =item host (default: empty)
76  
77 The <host>:<port> of the target policy daemon.
78  
79 =item socket_path (default: empty)
80  
81 The path to the socket of the target policy daemon.
82  
83 =item keepalive (default: 0)
84  
85 Keep connection open across requests.
86  
87 =back
88  
89 =head1 EXAMPLE
90  
91 <Plugin ask-postgrey>
92 module = "Proxy"
93 host="localhost:10023"
94 </Plugin>
95  
96 =head1 AUTHOR
97  
98 Markus Benning <ich@markusbenning.de>
99  
100 =head1 COPYRIGHT AND LICENSE
101  
102 This software is Copyright (c) 2014 by Markus Benning <ich@markusbenning.de>.
103  
104 This is free software, licensed under:
105  
106 The GNU General Public License, Version 2, June 1991
107  
108 =cut
109  
« MtPolicyd/Plugin/Fail2Ban.pm ↑ Summary MtPolicyd/PluginChain.pm »