line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::DDDS; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
28516
|
use 5.008008; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
36
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
194
|
|
5
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
199
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
require Exporter; |
8
|
1
|
|
|
1
|
|
879
|
use AutoLoader qw(AUTOLOAD); |
|
1
|
|
|
|
|
1533
|
|
|
1
|
|
|
|
|
5
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# Items to export into callers namespace by default. Note: do not export |
13
|
|
|
|
|
|
|
# names by default without a very good reason. Use EXPORT_OK instead. |
14
|
|
|
|
|
|
|
# Do not simply export all your public functions/methods/constants. |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# This allows declaration use Net::DDDS ':all'; |
17
|
|
|
|
|
|
|
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK |
18
|
|
|
|
|
|
|
# will save memory. |
19
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( 'all' => [ qw( |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
) ] ); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
our @EXPORT = qw( |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub new { |
32
|
1
|
|
|
1
|
0
|
23
|
my $this = shift; |
33
|
1
|
|
33
|
|
|
9
|
my $class = ref($this) || $this; |
34
|
1
|
|
|
|
|
4
|
my $self = bless { @_ }, $class; |
35
|
1
|
|
|
|
|
5
|
$self->init(); |
36
|
1
|
|
|
|
|
4
|
$self |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
0
|
0
|
0
|
sub init {} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub rules { |
42
|
0
|
|
|
0
|
0
|
0
|
my ($self,$key) = @_; |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
0
|
die "Must override: retrieve\n"; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub apply_first_rule { |
48
|
1
|
|
|
1
|
0
|
3
|
my ($self,$str) = @_; |
49
|
|
|
|
|
|
|
|
50
|
1
|
50
|
|
|
|
7
|
ref $self->{first_rule} eq 'CODE' ? $self->{first_rule}($str) : $str; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub accept_rule { |
54
|
0
|
|
|
0
|
0
|
0
|
my ($self,$rule) = @_; |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
0
|
die "Must override: accept_rule\n"; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub apply_rule { |
60
|
0
|
|
|
0
|
0
|
0
|
my ($self,$rule) = @_; |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
0
|
die "Must override: apply_rule\n"; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub lookup { |
67
|
2
|
|
|
2
|
0
|
14
|
my ($self,$str,$key) = @_; |
68
|
|
|
|
|
|
|
|
69
|
2
|
100
|
|
|
|
17
|
return $self->lookup($str,$self->apply_first_rule($str)) unless $key; |
70
|
1
|
|
|
|
|
2
|
my $result; |
71
|
1
|
|
|
|
|
10
|
foreach my $rule ($self->rules($key)) { |
72
|
1
|
50
|
|
|
|
10853
|
if ($self->accept_rule($rule)) { |
73
|
0
|
0
|
|
|
|
0
|
$result = $self->apply_rule($rule,$str) or next; |
74
|
|
|
|
|
|
|
|
75
|
0
|
0
|
|
|
|
0
|
return $result if $self->is_terminal($rule); |
76
|
0
|
|
|
|
|
0
|
return $self->lookup($str,$result); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
1
|
|
|
|
|
7
|
undef; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
package Net::DDDS::DNS; |
84
|
|
|
|
|
|
|
|
85
|
1
|
|
|
1
|
|
1403
|
use Net::DNS; |
|
1
|
|
|
|
|
150605
|
|
|
1
|
|
|
|
|
115
|
|
86
|
1
|
|
|
1
|
|
9
|
use base qw/Net::DDDS/; |
|
1
|
|
|
|
|
15
|
|
|
1
|
|
|
|
|
746
|
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub init { |
89
|
1
|
|
|
1
|
|
2
|
my ($self) = @_; |
90
|
1
|
|
|
|
|
22
|
$self->{_resolver} = Net::DNS::Resolver->new(); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub accept_rule { |
94
|
1
|
|
|
1
|
|
5
|
my ($self,$rule) = @_; |
95
|
|
|
|
|
|
|
|
96
|
1
|
50
|
33
|
|
|
13
|
return undef unless ref $rule && $rule->isa('Net::DNS::RR::NAPTR'); |
97
|
0
|
|
|
|
|
0
|
$rule->service =~ m{\Q$self->{service}\E}; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub is_terminal { |
101
|
0
|
|
|
0
|
|
0
|
my ($self,$rule) = @_; |
102
|
|
|
|
|
|
|
|
103
|
0
|
0
|
|
|
|
0
|
die "Bad rule" unless $rule->isa('Net::DNS::RR::NAPTR'); |
104
|
0
|
|
|
|
|
0
|
$rule->flags =~ /$self->{terminal}/; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub rules { |
108
|
1
|
|
|
1
|
|
3
|
my ($self,$key) = @_; |
109
|
1
|
50
|
|
|
|
12
|
my $result = $self->{_resolver}->query($key,'NAPTR') or return undef; |
110
|
0
|
|
|
|
|
0
|
$result->answer; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub apply_rule { |
114
|
0
|
|
|
0
|
|
0
|
my ($self,$rule,$key) = @_; |
115
|
|
|
|
|
|
|
|
116
|
0
|
0
|
|
|
|
0
|
die "Bad rule" unless $rule->isa('Net::DNS::RR::NAPTR'); |
117
|
|
|
|
|
|
|
|
118
|
0
|
0
|
0
|
|
|
0
|
die "Regexp and replacement both null: $rule\n" unless $rule->regexp || $rule->replacement; |
119
|
0
|
0
|
|
|
|
0
|
if ($rule->regexp) { |
120
|
0
|
|
|
|
|
0
|
my $delimc = substr($rule->regexp,0,1); |
121
|
0
|
|
|
|
|
0
|
my $mi = index($rule->regexp,$delimc,1); |
122
|
0
|
0
|
|
|
|
0
|
die "Bad regular expression: ".$rule->regexp."\n" if $mi == -1; |
123
|
0
|
|
|
|
|
0
|
my $ri = index($rule->regexp,$delimc,$mi+1); |
124
|
0
|
0
|
|
|
|
0
|
die "Bad regular expression: ".$rule->regexp."\n" if $ri == -1; |
125
|
0
|
|
|
|
|
0
|
my $match = substr($rule->regexp,1,$mi-1); |
126
|
0
|
|
|
|
|
0
|
my $repl = substr($rule->regexp,$mi+1,$ri-$mi-1); |
127
|
0
|
|
|
|
|
0
|
my $flags = substr($rule->regexp,$ri+1); |
128
|
0
|
|
|
|
|
0
|
$repl =~ s{\\([0-9]+)}{$$1}og; |
129
|
0
|
|
|
|
|
0
|
$key =~ s{$match}{$repl}; |
130
|
0
|
|
|
|
|
0
|
return $key; |
131
|
|
|
|
|
|
|
} else { |
132
|
0
|
|
|
|
|
0
|
return $rule->replacement; |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
package Net::DDDS::ENUM; |
137
|
1
|
|
|
1
|
|
7
|
use base qw/Net::DDDS::DNS/; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
711
|
|
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
sub enum_first_rule { |
140
|
1
|
|
|
1
|
|
4
|
my ($str) = @_; |
141
|
|
|
|
|
|
|
|
142
|
1
|
|
|
|
|
8
|
$str =~ s/[^0-9]//og; |
143
|
1
|
|
|
|
|
11
|
my $x = sprintf "%s.e164.arpa",join('.',reverse(split '',$str)); |
144
|
1
|
|
|
|
|
9
|
$x; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
sub init { |
148
|
1
|
|
|
1
|
|
3
|
my ($self) = @_; |
149
|
|
|
|
|
|
|
|
150
|
1
|
|
|
|
|
9
|
$self->SUPER::init(); |
151
|
|
|
|
|
|
|
|
152
|
1
|
|
|
|
|
638
|
$self->{terminal} = 'u'; |
153
|
1
|
|
|
|
|
3
|
$self->{service} = 'E2U+sip'; |
154
|
1
|
|
|
|
|
3
|
$self->{first_rule} = \&enum_first_rule; |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
package Net::DDDS::SAMLMetadata; |
158
|
1
|
|
|
1
|
|
11
|
use base qw/Net::DDDS::DNS/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
501
|
|
159
|
1
|
|
|
1
|
|
1121
|
use URI; |
|
1
|
|
|
|
|
9384
|
|
|
1
|
|
|
|
|
164
|
|
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
sub samlmd_first_rule { |
162
|
0
|
|
|
0
|
|
|
my ($str) = @_; |
163
|
|
|
|
|
|
|
|
164
|
0
|
|
|
|
|
|
my $u = URI->new($str); |
165
|
0
|
|
|
|
|
|
$u->host; |
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
sub init { |
169
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
170
|
|
|
|
|
|
|
|
171
|
0
|
|
|
|
|
|
$self->SUPER::init(); |
172
|
0
|
|
|
|
|
|
$self->{terminal} = "U"; |
173
|
0
|
|
|
|
|
|
$self->{service} = "PID2U+http"; |
174
|
0
|
|
|
|
|
|
$self->{first_rule} = \&samlmd_first_rule; |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
package Net::DDDS; |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
# Preloaded methods go here. |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
# Autoload methods go after =cut, and are processed by the autosplit program. |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
1; |
184
|
|
|
|
|
|
|
__END__ |