| 1 | package Mail::STS; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 1 | our $VERSION = '0.04'; # VERSION | |||||||||
| 6 | # ABSTRACT: library for looking up MTA-STS policies | ||||||||||
| 7 | |||||||||||
| 8 | 1 | ▶ | use LWP::UserAgent; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 1 | ▶ | use Net::DNS::Resolver; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 1 | ▶ | use Mail::STS::Domain; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | |||||||||||
| 14 | 1 | has 'agent_timeout' => ( | |||||||||
| 15 | is => 'ro', | ||||||||||
| 16 | isa => 'Int', | ||||||||||
| 17 | default => 60, | ||||||||||
| 18 | ); | ||||||||||
| 19 | |||||||||||
| 20 | |||||||||||
| 21 | 1 | has 'max_policy_size' => ( | |||||||||
| 22 | is => 'rw', | ||||||||||
| 23 | isa => 'Maybe[Int]', | ||||||||||
| 24 | default => 65536, | ||||||||||
| 25 | ); | ||||||||||
| 26 | |||||||||||
| 27 | |||||||||||
| 28 | has 'resolver' => ( | ||||||||||
| 29 | is => 'ro', | ||||||||||
| 30 | isa => 'Net::DNS::Resolver', | ||||||||||
| 31 | lazy => 1, | ||||||||||
| 32 | default => sub { | ||||||||||
| 33 | 0 | ▶ | return Net::DNS::Resolver->new( | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 34 | dnssec => 1, | ||||||||||
| 35 | adflag => 1, | ||||||||||
| 36 | ); | ||||||||||
| 37 | }, | ||||||||||
| 38 | 1 | ); | |||||||||
| 39 | |||||||||||
| 40 | |||||||||||
| 41 | has 'agent' => ( | ||||||||||
| 42 | is => 'ro', | ||||||||||
| 43 | isa => 'LWP::UserAgent', | ||||||||||
| 44 | lazy => 1, | ||||||||||
| 45 | default => sub { | ||||||||||
| 46 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||
| 47 | 0 | my $agent = LWP::UserAgent->new( | |||||||||
| 48 | agent => 'Mail::STS', | ||||||||||
| 49 | max_redirect => 0, | ||||||||||
| 50 | requests_redirectable => [], | ||||||||||
| 51 | protocols_allowed => ['https'], | ||||||||||
| 52 | timeout => $self->agent_timeout, | ||||||||||
| 53 | ); | ||||||||||
| 54 | 0 | $agent->ssl_opts(verify_hostname => 1); | |||||||||
| 55 | 0 | ▶ | $agent->ssl_opts(ssl_ca_file => $self->ssl_ca_file) if defined $self->ssl_ca_file; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 56 | 0 | ▶ | $agent->ssl_opts(ssl_ca_path => $self->ssl_ca_path) if defined $self->ssl_ca_path; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 57 | 0 | return $agent; | |||||||||
| 58 | }, | ||||||||||
| 59 | 1 | handles => [ 'ssl_opts', 'proxy', 'no_proxy', 'env_proxy' ], | |||||||||
| 60 | ); | ||||||||||
| 61 | |||||||||||
| 62 | |||||||||||
| 63 | 1 | has 'ssl_ca_file' => ( | |||||||||
| 64 | is => 'ro', | ||||||||||
| 65 | isa => 'Maybe[Str]', | ||||||||||
| 66 | ); | ||||||||||
| 67 | |||||||||||
| 68 | |||||||||||
| 69 | 1 | has 'ssl_ca_path' => ( | |||||||||
| 70 | is => 'ro', | ||||||||||
| 71 | isa => 'Maybe[Str]', | ||||||||||
| 72 | ); | ||||||||||
| 73 | |||||||||||
| 74 | |||||||||||
| 75 | sub domain { | ||||||||||
| 76 | 0 | ▶ | my ($self, $domain) = @_; | ||||||||
|
Subroutine
domain: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 77 | 0 | return Mail::STS::Domain->new( | |||||||||
| 78 | resolver => $self->resolver, | ||||||||||
| 79 | agent => $self->agent, | ||||||||||
| 80 | max_policy_size => $self->max_policy_size, | ||||||||||
| 81 | domain => $domain, | ||||||||||
| 82 | ); | ||||||||||
| 83 | } | ||||||||||
| 84 | |||||||||||
| 85 | |||||||||||
| 86 | 1 | 1; | |||||||||
| 87 | |||||||||||
| 88 | __END__ | ||||||||||
| 89 | |||||||||||
| 90 | =pod | ||||||||||
| 91 | |||||||||||
| 92 | =encoding UTF-8 | ||||||||||
| 93 | |||||||||||
| 94 | =head1 NAME | ||||||||||
| 95 | |||||||||||
| 96 | Mail::STS - library for looking up MTA-STS policies | ||||||||||
| 97 | |||||||||||
| 98 | =head1 VERSION | ||||||||||
| 99 | |||||||||||
| 100 | version 0.04 | ||||||||||
| 101 | |||||||||||
| 102 | =head1 SYNOPSIS | ||||||||||
| 103 | |||||||||||
| 104 | my $sts = Mail::STS->new; | ||||||||||
| 105 | $domain = $sts->domain('domain.de'); | ||||||||||
| 106 | |||||||||||
| 107 | # may try dane first? | ||||||||||
| 108 | return 'dane' if $domain->tlsa; | ||||||||||
| 109 | |||||||||||
| 110 | # has a TLSRPT record? | ||||||||||
| 111 | $domain->tlsrpt | ||||||||||
| 112 | # undef or Mail::STS::TLSRPTRecord | ||||||||||
| 113 | |||||||||||
| 114 | $domain->sts; | ||||||||||
| 115 | # undef or Mail::STS::STSRecord | ||||||||||
| 116 | $domain->sts->id; | ||||||||||
| 117 | # 12345... | ||||||||||
| 118 | |||||||||||
| 119 | $policy = $domain->policy; | ||||||||||
| 120 | # Mail::STS::Policy or will die on error | ||||||||||
| 121 | $policy->mode; | ||||||||||
| 122 | # 'enforce', 'testing' or 'none' | ||||||||||
| 123 | $policy->mx; | ||||||||||
| 124 | # ['mta1.example.net', '*.example.de', ...] | ||||||||||
| 125 | $policy->match_mx('whatever.example.de'); | ||||||||||
| 126 | # 1 | ||||||||||
| 127 | |||||||||||
| 128 | =head1 DESCRIPTION | ||||||||||
| 129 | |||||||||||
| 130 | This class provides an interface for looking up RFC8461 | ||||||||||
| 131 | MTA-STS policies. | ||||||||||
| 132 | |||||||||||
| 133 | =head1 ATTRIBUTES | ||||||||||
| 134 | |||||||||||
| 135 | =head2 agent_timeout(default: 60) | ||||||||||
| 136 | |||||||||||
| 137 | Set default for http agent for policy retrieval. | ||||||||||
| 138 | |||||||||||
| 139 | A timeout of one minute is suggested. | ||||||||||
| 140 | |||||||||||
| 141 | =head2 max_policy_size(default: 65536) | ||||||||||
| 142 | |||||||||||
| 143 | Maximum size for STS policy documents in bytes. | ||||||||||
| 144 | |||||||||||
| 145 | =head2 resolver | ||||||||||
| 146 | |||||||||||
| 147 | By default will use a Net::DNS::Resolver with dnssec/adflag enabled. | ||||||||||
| 148 | |||||||||||
| 149 | Could be used to provide a custom Net::DNS::Resolver object. | ||||||||||
| 150 | |||||||||||
| 151 | =head2 agent | ||||||||||
| 152 | |||||||||||
| 153 | By default will initialize a new LWP::UserAgent with | ||||||||||
| 154 | parameters take from this object. | ||||||||||
| 155 | |||||||||||
| 156 | =head2 ssl_opts, proxy, no_proxy, env_proxy | ||||||||||
| 157 | |||||||||||
| 158 | These methods are delegated to the LWP::UserAgent object. | ||||||||||
| 159 | |||||||||||
| 160 | See L<LWP::UserAgent> for details. | ||||||||||
| 161 | |||||||||||
| 162 | =head2 ssl_ca_file (default: undef) | ||||||||||
| 163 | |||||||||||
| 164 | Set a ssl_ca_file for the default LWP::UserAgent. | ||||||||||
| 165 | |||||||||||
| 166 | =head2 ssl_ca_path (default: undef) | ||||||||||
| 167 | |||||||||||
| 168 | Set a ssl_ca_path for the default LWP::UserAgent. | ||||||||||
| 169 | |||||||||||
| 170 | =head1 METHODS | ||||||||||
| 171 | |||||||||||
| 172 | =head2 domain($domain) | ||||||||||
| 173 | |||||||||||
| 174 | Returns a Mail::STS::Domain object for $domain | ||||||||||
| 175 | for lookup of domain details. | ||||||||||
| 176 | |||||||||||
| 177 | =head1 SEE ALSO | ||||||||||
| 178 | |||||||||||
| 179 | L<Mail::STS::Domain>, L<Mail::STS::Policy>, L<Mail::STS::TLSRPTRecord>, L<Mail::STS::STSRecord> | ||||||||||
| 180 | |||||||||||
| 181 | =head1 AUTHOR | ||||||||||
| 182 | |||||||||||
| 183 | Markus Benning <ich@markusbenning.de> | ||||||||||
| 184 | |||||||||||
| 185 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 186 | |||||||||||
| 187 | This software is copyright (c) 2018 by Markus Benning <ich@markusbenning.de>. | ||||||||||
| 188 | |||||||||||
| 189 | This is free software; you can redistribute it and/or modify it under | ||||||||||
| 190 | the same terms as the Perl 5 programming language system itself. | ||||||||||
| 191 | |||||||||||
| 192 | =cut | ||||||||||