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