| 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 = '2.01'; # 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
| |||||||||||||||
| 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 | __END__ | ||||||||||||||
| 56 | |||||||||||||||
| 57 | =pod | ||||||||||||||
| 58 | |||||||||||||||
| 59 | =encoding UTF-8 | ||||||||||||||
| 60 | |||||||||||||||
| 61 | =head1 NAME | ||||||||||||||
| 62 | |||||||||||||||
| 63 | Mail::MtPolicyd::Plugin::Proxy - mtpolicyd plugin to forward request to another policy daemon | ||||||||||||||
| 64 | |||||||||||||||
| 65 | =head1 VERSION | ||||||||||||||
| 66 | |||||||||||||||
| 67 | version 2.01 | ||||||||||||||
| 68 | |||||||||||||||
| 69 | =head1 DESCRIPTION | ||||||||||||||
| 70 | |||||||||||||||
| 71 | This module forwards the request to another policy daemon. | ||||||||||||||
| 72 | |||||||||||||||
| 73 | =head1 PARAMETERS | ||||||||||||||
| 74 | |||||||||||||||
| 75 | =over | ||||||||||||||
| 76 | |||||||||||||||
| 77 | =item host (default: empty) | ||||||||||||||
| 78 | |||||||||||||||
| 79 | The <host>:<port> of the target policy daemon. | ||||||||||||||
| 80 | |||||||||||||||
| 81 | =item socket_path (default: empty) | ||||||||||||||
| 82 | |||||||||||||||
| 83 | The path to the socket of the target policy daemon. | ||||||||||||||
| 84 | |||||||||||||||
| 85 | =item keepalive (default: 0) | ||||||||||||||
| 86 | |||||||||||||||
| 87 | Keep connection open across requests. | ||||||||||||||
| 88 | |||||||||||||||
| 89 | =back | ||||||||||||||
| 90 | |||||||||||||||
| 91 | =head1 EXAMPLE | ||||||||||||||
| 92 | |||||||||||||||
| 93 | <Plugin ask-postgrey> | ||||||||||||||
| 94 | module = "Proxy" | ||||||||||||||
| 95 | host="localhost:10023" | ||||||||||||||
| 96 | </Plugin> | ||||||||||||||
| 97 | |||||||||||||||
| 98 | =head1 AUTHOR | ||||||||||||||
| 99 | |||||||||||||||
| 100 | Markus Benning <ich@markusbenning.de> | ||||||||||||||
| 101 | |||||||||||||||
| 102 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||
| 103 | |||||||||||||||
| 104 | This software is Copyright (c) 2014 by Markus Benning <ich@markusbenning.de>. | ||||||||||||||
| 105 | |||||||||||||||
| 106 | This is free software, licensed under: | ||||||||||||||
| 107 | |||||||||||||||
| 108 | The GNU General Public License, Version 2, June 1991 | ||||||||||||||
| 109 | |||||||||||||||
| 110 | =cut | ||||||||||||||