| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Mail::MtPolicyd::Client::Response; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
6
|
use Moose; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '2.01'; # VERSION |
|
6
|
|
|
|
|
|
|
# ABSTRACT: a postfix policyd client response class |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has 'action' => ( is => 'ro', isa => 'Str', required => 1 ); |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has 'attributes' => ( |
|
12
|
|
|
|
|
|
|
is => 'ro', isa => 'HashRef[Str]', |
|
13
|
|
|
|
|
|
|
default => sub { {} }, |
|
14
|
|
|
|
|
|
|
); |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub as_string { |
|
17
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
return join("\n", |
|
20
|
0
|
|
|
|
|
|
map { $_.'='.$self->attributes->{$_} } keys %{$self->attributes}, |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
)."\n\n"; |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub new_from_fh { |
|
25
|
0
|
|
|
0
|
1
|
|
my ( $class, $fh ) = ( shift, shift ); |
|
26
|
0
|
|
|
|
|
|
my $attr = {}; |
|
27
|
0
|
|
|
|
|
|
my $complete = 0; |
|
28
|
0
|
|
|
|
|
|
while( my $line = $fh->getline ) { |
|
29
|
0
|
|
|
|
|
|
$line =~ s/\r?\n$//; |
|
30
|
0
|
0
|
|
|
|
|
if( $line eq '') { $complete = 1 ; last; } |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
my ( $name, $value ) = split('=', $line, 2); |
|
32
|
0
|
0
|
|
|
|
|
if( ! defined $value ) { |
|
33
|
0
|
|
|
|
|
|
die('error parsing response'); |
|
34
|
|
|
|
|
|
|
} |
|
35
|
0
|
|
|
|
|
|
$attr->{$name} = $value; |
|
36
|
|
|
|
|
|
|
} |
|
37
|
0
|
0
|
|
|
|
|
if( ! $complete ) { |
|
38
|
0
|
|
|
|
|
|
die('could not read response'); |
|
39
|
|
|
|
|
|
|
} |
|
40
|
0
|
0
|
|
|
|
|
if( ! defined $attr->{'action'} ) { |
|
41
|
0
|
|
|
|
|
|
die('no action found in response'); |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
my $obj = $class->new( |
|
44
|
0
|
|
|
|
|
|
'action' => $attr->{'action'}, |
|
45
|
|
|
|
|
|
|
'attributes' => $attr, |
|
46
|
|
|
|
|
|
|
@_ |
|
47
|
|
|
|
|
|
|
); |
|
48
|
0
|
|
|
|
|
|
return $obj; |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
__END__ |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=pod |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=encoding UTF-8 |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 NAME |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Mail::MtPolicyd::Client::Response - a postfix policyd client response class |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 VERSION |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
version 2.01 |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Class to handle a policyd response. |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head2 SYNOPSIS |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
use Mail::MtPolicyd::Client::Response; |
|
74
|
|
|
|
|
|
|
my $response = Mail::MtPolicyd::Client::Response->new_from_fh( $conn ); |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
-- |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
my $response = Mail::MtPolicyd::Client::Response->new( |
|
79
|
|
|
|
|
|
|
action => 'reject', |
|
80
|
|
|
|
|
|
|
attributes => { |
|
81
|
|
|
|
|
|
|
action => 'reject', |
|
82
|
|
|
|
|
|
|
}, |
|
83
|
|
|
|
|
|
|
); |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
print $response->as_string; |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 METHODS |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=over |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=item new_from_fh( $filehandle ) |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Constructor which reads a response from the supplied filehandle. |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=item as_string |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Returns a stringified version of the response. |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=back |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head2 ATTRIBUTES |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=over |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=item action (required) |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
The action specified in the reponse. |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=item attributes |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Holds a hash with all key/values of the response. |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=back |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 AUTHOR |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Markus Benning <ich@markusbenning.de> |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
This software is Copyright (c) 2014 by Markus Benning <ich@markusbenning.de>. |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
This is free software, licensed under: |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
The GNU General Public License, Version 2, June 1991 |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=cut |