line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mail::MtPolicyd::Plugin::Proxy; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1952
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
4
|
1
|
|
|
1
|
|
5994
|
use namespace::autoclean; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
13
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '2.02'; # VERSION |
7
|
|
|
|
|
|
|
# ABSTRACT: mtpolicyd plugin to forward request to another policy daemon |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
extends 'Mail::MtPolicyd::Plugin'; |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
125
|
use Mail::MtPolicyd::Plugin::Result; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
35
|
|
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
7
|
use Mail::MtPolicyd::Client; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
15
|
1
|
|
|
1
|
|
8
|
use Mail::MtPolicyd::Client::Request; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
353
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has 'socket_path' => ( is => 'rw', isa => 'Maybe[Str]' ); |
18
|
|
|
|
|
|
|
has 'host' => ( is => 'rw', isa => 'Maybe[Str]' ); |
19
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
my $self = shift; |
25
|
|
|
|
|
|
|
my %opts = ( |
26
|
|
|
|
|
|
|
keepalive => $self->keepalive, |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
if( defined $self->socket_path ) { |
29
|
|
|
|
|
|
|
$opts{'socket_path'} = $self->socket_path; |
30
|
|
|
|
|
|
|
} elsif( defined $self->host ) { |
31
|
|
|
|
|
|
|
$opts{'host'} = $self->host; |
32
|
|
|
|
|
|
|
} else { |
33
|
|
|
|
|
|
|
$self->logdie('no host and no socket_path configured!'); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
return Mail::MtPolicyd::Client->new( %opts ); |
36
|
|
|
|
|
|
|
}, |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub run { |
40
|
0
|
|
|
0
|
1
|
|
my ( $self, $r ) = @_; |
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
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
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.02 |
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 |