line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PGP::Finger::DNS; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
3
|
use Moose; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
4
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
extends 'PGP::Finger::Source'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# ABSTRACT: gpgfinger source to query DNS for OPENPGPKEYs |
8
|
|
|
|
|
|
|
our $VERSION = '1.1'; # VERSION |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
4617
|
use Net::DNS::Resolver; |
|
1
|
|
|
|
|
63845
|
|
|
1
|
|
|
|
|
31
|
|
11
|
1
|
|
|
1
|
|
433
|
use Digest::SHA qw(sha224_hex); |
|
1
|
|
|
|
|
2135
|
|
|
1
|
|
|
|
|
62
|
|
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
306
|
use PGP::Finger::Result; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
29
|
|
14
|
1
|
|
|
1
|
|
353
|
use PGP::Finger::Key; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
297
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has 'dnssec' => ( is => 'rw', isa => 'Bool', default => 1 ); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has _resolver => ( is => 'ro', isa => 'Net::DNS::Resolver', lazy => 1, |
19
|
|
|
|
|
|
|
default => sub { |
20
|
|
|
|
|
|
|
my $self = shift; |
21
|
|
|
|
|
|
|
my $res = Net::DNS::Resolver->new; |
22
|
|
|
|
|
|
|
$res->dnssec( $self->dnssec ); |
23
|
|
|
|
|
|
|
return( $res ); |
24
|
|
|
|
|
|
|
}, |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
has 'rr_types' => ( is => 'rw', isa => 'ArrayRef[Str]', |
28
|
|
|
|
|
|
|
default => sub { [ 'TYPE61' ] }, |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub fetch { |
32
|
0
|
|
|
0
|
0
|
|
my ( $self, $addr ) = @_; |
33
|
0
|
|
|
|
|
|
my ($local, $domain) = split('@', $addr, 2); |
34
|
0
|
0
|
0
|
|
|
|
if( ! defined $local || ! defined $domain ) { |
35
|
0
|
|
|
|
|
|
die("could not parse mail address $addr"); |
36
|
|
|
|
|
|
|
} |
37
|
0
|
|
|
|
|
|
my $record = join('.', sha224_hex($local), '_openpgpkey', $domain); |
38
|
0
|
|
|
|
|
|
my $result = PGP::Finger::Result->new; |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
foreach my $rr_type ( @{$self->rr_types} ) { |
|
0
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
my $reply = $self->_resolver->query( $record, $rr_type ); |
42
|
0
|
0
|
|
|
|
|
if( ! defined $reply ) { |
43
|
0
|
|
|
|
|
|
die("error while looking up $rr_type: ".$self->_resolver->errorstring); |
44
|
|
|
|
|
|
|
} |
45
|
0
|
|
|
|
|
|
foreach my $rr ( $reply->answer ) { |
46
|
0
|
0
|
|
|
|
|
if($rr->type ne $rr_type ) { |
47
|
0
|
|
|
|
|
|
next; |
48
|
|
|
|
|
|
|
} |
49
|
0
|
|
|
|
|
|
my $key = PGP::Finger::Key->new( |
50
|
|
|
|
|
|
|
mail => $addr, |
51
|
|
|
|
|
|
|
data => $rr->rdata, |
52
|
|
|
|
|
|
|
); |
53
|
0
|
|
|
|
|
|
$key->set_attr( source => 'DNS' ); |
54
|
0
|
|
|
|
|
|
$key->set_attr( domain => $domain ); |
55
|
0
|
0
|
|
|
|
|
$key->set_attr( dnssec => $reply->header->ad ? 'ok' : 'unauthenticated' ); |
56
|
0
|
|
|
|
|
|
$result->add_key( $key ); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
return $result; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
__END__ |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=pod |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=encoding UTF-8 |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 NAME |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
PGP::Finger::DNS - gpgfinger source to query DNS for OPENPGPKEYs |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 VERSION |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
version 1.1 |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 AUTHOR |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Markus Benning <ich@markusbenning.de> |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
This software is Copyright (c) 2015 by Markus Benning. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
This is free software, licensed under: |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
The GNU General Public License, Version 2 or later |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=cut |