line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mail::MtPolicyd::Plugin::Stress; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1409
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
4
|
1
|
|
|
1
|
|
5671
|
use namespace::autoclean; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '2.02'; # VERSION |
7
|
|
|
|
|
|
|
# ABSTRACT: mtpolicyd plugin for postfix stress mode |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
extends 'Mail::MtPolicyd::Plugin'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
with 'Mail::MtPolicyd::Plugin::Role::UserConfig' => { |
12
|
|
|
|
|
|
|
'uc_attributes' => [ 'action' ], |
13
|
|
|
|
|
|
|
}; |
14
|
|
|
|
|
|
|
with 'Mail::MtPolicyd::Plugin::Role::PluginChain'; |
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
|
101
|
use Mail::MtPolicyd::Plugin::Result; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
164
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has 'action' => ( is => 'rw', isa => 'Maybe[Str]' ); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub run { |
22
|
0
|
|
|
0
|
1
|
|
my ( $self, $r ) = @_; |
23
|
0
|
|
|
|
|
|
my $session = $r->session; |
24
|
0
|
|
|
|
|
|
my $stress = $r->attr('stress'); |
25
|
|
|
|
|
|
|
|
26
|
0
|
0
|
0
|
|
|
|
if( defined $stress && $stress eq 'yes' ) { |
27
|
0
|
|
|
|
|
|
$self->log($r, 'MTA has stress feature turned on'); |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
my $action = $self->get_uc($session, 'action'); |
30
|
0
|
0
|
|
|
|
|
if( defined $action ) { |
31
|
0
|
|
|
|
|
|
return Mail::MtPolicyd::Plugin::Result->new( |
32
|
|
|
|
|
|
|
action => $action, |
33
|
|
|
|
|
|
|
abort => 1, |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
} |
36
|
0
|
0
|
|
|
|
|
if( defined $self->chain ) { |
37
|
0
|
|
|
|
|
|
my $chain_result = $self->chain->run( $r ); |
38
|
0
|
|
|
|
|
|
return( @{$chain_result->plugin_results} ); |
|
0
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
return; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
__END__ |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=pod |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=encoding UTF-8 |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 NAME |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Mail::MtPolicyd::Plugin::Stress - mtpolicyd plugin for postfix stress mode |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 VERSION |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
version 2.02 |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 DESCRIPTION |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Will return an action or execute futher plugins if postfix signals stress. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
See postfix STRESS_README. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 PARAMETERS |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
An action must be specified: |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=over |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=item action (default: empty) |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
The action to return when under stress. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=item Plugin (default: empty) |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Execute this plugins when under stress. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=back |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 EXAMPLE: defer clients when under stress |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
To defer clients under stress: |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
<Plugin stress> |
90
|
|
|
|
|
|
|
module = "Stress" |
91
|
|
|
|
|
|
|
action = "defer please try again later" |
92
|
|
|
|
|
|
|
</Plugin> |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
This will return an defer action and execute no futher tests. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
You may want to do some whitelisting for preferred clients before this action. |
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 |