line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mail::MtPolicyd::Client::App; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
2416
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '2.01'; # VERSION |
6
|
|
|
|
|
|
|
# ABSTRACT: application interface class for Mail::MtPolicyd::Client |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
extends 'Mail::MtPolicyd::Client'; |
10
|
|
|
|
|
|
|
with 'MooseX::Getopt'; |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
4405
|
use Mail::MtPolicyd::Client::Request; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
28
|
|
13
|
1
|
|
|
1
|
|
5
|
use IO::Handle; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
240
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has '+host' => ( |
16
|
|
|
|
|
|
|
traits => ['Getopt'], |
17
|
|
|
|
|
|
|
cmd_aliases => "h", |
18
|
|
|
|
|
|
|
documentation => "host:port of a policyd", |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has '+socket_path' => ( |
22
|
|
|
|
|
|
|
traits => ['Getopt'], |
23
|
|
|
|
|
|
|
cmd_aliases => "s", |
24
|
|
|
|
|
|
|
documentation => "path to a socket of a policyd", |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
has '+keepalive' => ( |
29
|
|
|
|
|
|
|
traits => ['Getopt'], |
30
|
|
|
|
|
|
|
cmd_aliases => "k", |
31
|
|
|
|
|
|
|
documentation => "use connection keepalive?", |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
has 'verbose' => ( |
35
|
|
|
|
|
|
|
is => 'rw', |
36
|
|
|
|
|
|
|
isa => 'Bool', |
37
|
|
|
|
|
|
|
default => 0, |
38
|
|
|
|
|
|
|
traits => ['Getopt'], |
39
|
|
|
|
|
|
|
cmd_aliases => "v", |
40
|
|
|
|
|
|
|
documentation => "be verbose, print input/output to STDERR", |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub run { |
44
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
45
|
0
|
|
|
|
|
|
my $stdin = IO::Handle->new; |
46
|
0
|
|
|
|
|
|
$stdin->fdopen(fileno(STDIN),"r"); |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
while( my $request = Mail::MtPolicyd::Client::Request->new_from_fh( $stdin ) ) { |
49
|
0
|
0
|
|
|
|
|
if( $self->verbose ) { |
50
|
0
|
|
|
|
|
|
$self->_dump('>> ', $request->as_string); |
51
|
|
|
|
|
|
|
} |
52
|
0
|
|
|
|
|
|
my $response = $self->request( $request ); |
53
|
0
|
0
|
|
|
|
|
if( $self->verbose ) { |
54
|
0
|
|
|
|
|
|
$self->_dump('<< ', $response->as_string); |
55
|
|
|
|
|
|
|
} |
56
|
0
|
|
|
|
|
|
print $response->action."\n"; |
57
|
|
|
|
|
|
|
} |
58
|
0
|
|
|
|
|
|
return; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub _dump { |
62
|
0
|
|
|
0
|
|
|
my ( $self, $prefix, $message ) = @_; |
63
|
0
|
|
|
|
|
|
$message =~ s/^/$prefix/mg; |
64
|
0
|
|
|
|
|
|
print STDERR $message; |
65
|
0
|
|
|
|
|
|
return; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
__END__ |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=pod |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=encoding UTF-8 |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 NAME |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Mail::MtPolicyd::Client::App - application interface class for Mail::MtPolicyd::Client |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 VERSION |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
version 2.01 |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 SYNOPSIS |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
use Mail::MtPolicyd::Client::App; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
my $app = Mail::MtPolicyd::Client::App->new_with_options(); |
90
|
|
|
|
|
|
|
$app->run; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 DESCRIPTION |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
This class provides a application interface for Mail::MtPolicyd::Client. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 SEE ALSO |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
L<policyd-client>, L<Mail::MtPolicyd::Client> |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 AUTHOR |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Markus Benning <ich@markusbenning.de> |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
This software is Copyright (c) 2014 by Markus Benning <ich@markusbenning.de>. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
This is free software, licensed under: |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
The GNU General Public License, Version 2, June 1991 |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=cut |