line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mail::MtPolicyd::Plugin; |
2
|
|
|
|
|
|
|
|
3
|
18
|
|
|
18
|
|
14531
|
use Moose; |
|
18
|
|
|
|
|
40
|
|
|
18
|
|
|
|
|
171
|
|
4
|
18
|
|
|
18
|
|
115118
|
use namespace::autoclean; |
|
18
|
|
|
|
|
8167
|
|
|
18
|
|
|
|
|
170
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '1.23'; # VERSION |
7
|
|
|
|
|
|
|
# ABSTRACT: a base class for plugins |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has 'name' => ( is => 'rw', isa => 'Str', required => 1 ); |
11
|
|
|
|
|
|
|
has 'log_level' => ( is => 'ro', isa => 'Int', default => 4 ); |
12
|
|
|
|
|
|
|
has 'vhost_name' => ( is => 'ro', isa => 'Maybe[Str]' ); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has 'on_error' => ( is => 'ro', isa => 'Maybe[Str]' ); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub run { |
18
|
0
|
|
|
0
|
1
|
0
|
my ( $self, $r ) = @_; |
19
|
0
|
|
|
|
|
0
|
die('plugin did not implement run method!'); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub log { |
23
|
131
|
|
|
131
|
1
|
987
|
my ($self, $r, $msg) = @_; |
24
|
131
|
50
|
|
|
|
5475
|
if( defined $self->vhost_name ) { |
25
|
0
|
|
|
|
|
0
|
$msg = $self->vhost_name.': '.$msg; |
26
|
|
|
|
|
|
|
} |
27
|
131
|
|
|
|
|
5344
|
$r->log($self->log_level, $msg); |
28
|
|
|
|
|
|
|
|
29
|
131
|
|
|
|
|
34692
|
return; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub init { |
33
|
4
|
|
|
4
|
0
|
2536
|
return; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub cron { |
37
|
0
|
|
|
0
|
0
|
|
return; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
1; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
__END__ |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=pod |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=encoding UTF-8 |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 NAME |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Mail::MtPolicyd::Plugin - a base class for plugins |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 VERSION |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
version 1.23 |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head2 name |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Contains a string with the name of this plugin as specified in the configuration. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 log_level (default: 4) |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
The log_level used when the plugin calls $self->log( $r, $msg ). |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 METHODS |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head2 run( $r ) |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
This method has be implemented by the plugin which inherits from this base class. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head2 log( $r, $msg ) |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
This method could be used by the plugin to log something. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Since this is mostly for debugging the default is to log plugin specific |
79
|
|
|
|
|
|
|
messages with log_level=4. (see log_level attribute) |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 AUTHOR |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Markus Benning <ich@markusbenning.de> |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
This software is Copyright (c) 2014 by Markus Benning <ich@markusbenning.de>. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
This is free software, licensed under: |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
The GNU General Public License, Version 2, June 1991 |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |