| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package EPFL::Net::ipv6Test; |
|
2
|
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
102431
|
use 5.006; |
|
|
3
|
|
|
|
|
26
|
|
|
4
|
3
|
|
|
3
|
|
12
|
use strict; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
80
|
|
|
5
|
3
|
|
|
3
|
|
17
|
use warnings; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
67
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
1452
|
use JSON; |
|
|
3
|
|
|
|
|
23991
|
|
|
|
3
|
|
|
|
|
12
|
|
|
8
|
3
|
|
|
3
|
|
1480
|
use Readonly; |
|
|
3
|
|
|
|
|
7962
|
|
|
|
3
|
|
|
|
|
123
|
|
|
9
|
3
|
|
|
3
|
|
1576
|
use LWP::UserAgent; |
|
|
3
|
|
|
|
|
103863
|
|
|
|
3
|
|
|
|
|
143
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
EPFL::Net::ipv6Test - Website IPv6 accessibility validator API |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 VERSION |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Version 1.01 |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=cut |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our $VERSION = '1.01'; |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Check IPv6 connectivity from a Website with ipv6-test.com |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
use EPFL::Net::ipv6Test qw/getWebAAAA getWebServer getWebDns/; |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my $aaaa = getWebAAAA('google.com'); |
|
30
|
|
|
|
|
|
|
print $aaaa->{dns_aaaa}; # => '2400:cb00:2048:1::6814:e52a' |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my $aaaa = getWebServer('google.com'); |
|
33
|
|
|
|
|
|
|
print $aaaa->{dns_aaaa}; # => '2400:cb00:2048:1::6814:e52a' |
|
34
|
|
|
|
|
|
|
print $aaaa->{server}; # => 'gws' |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my $dns = getWebDns('google.com'); |
|
37
|
|
|
|
|
|
|
print $dns->{dns_ok}; # => 1 |
|
38
|
|
|
|
|
|
|
print @{$dns->{dns_servers}}; |
|
39
|
|
|
|
|
|
|
# => 'ns3.google.comns2.google.comns1.google.comns4.google.com' |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Via the command line epfl-net-ipv6-test |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
A simple module to validate IPv6 accessibility of a Website |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=cut |
|
48
|
|
|
|
|
|
|
|
|
49
|
3
|
|
|
3
|
|
22
|
use base 'Exporter'; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
1241
|
|
|
50
|
|
|
|
|
|
|
our @EXPORT_OK = |
|
51
|
|
|
|
|
|
|
qw/getWebAAAA getWebServer getWebDns p_createUserAgent p_getUrl p_buildUrl/; |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Readonly::Scalar my $WEB_AAAA => 'http://ipv6-test.com/json/webaaaa.php'; |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Readonly::Scalar my $WEB_SERVER => 'http://ipv6-test.com/json/webserver.php'; |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Readonly::Scalar my $WEB_DNS => 'http://ipv6-test.com/json/webdns.php'; |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Readonly::Scalar my $MAX_REDIRECT => 10; |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Readonly::Scalar my $TIMEOUT => 1200; |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head2 getWebAAAA( $domain ) |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Return the AAAA DNS record. |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Example: |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
{'dns_aaaa' => '2400:cb00:2048:1::6814:e52a'} |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
or |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
{'dns_aaaa' => 'null', 'error' => 'no AAAA record'} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=cut |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub getWebAAAA { |
|
80
|
4
|
|
|
4
|
1
|
4654
|
my $domain = shift; |
|
81
|
4
|
100
|
|
|
|
18
|
return if not defined $domain; |
|
82
|
|
|
|
|
|
|
|
|
83
|
3
|
|
|
|
|
10
|
return p_getWebAPI( $WEB_AAAA, $domain, 1 ); |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 getWebServer( $domain ) |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Return the AAAA DNS record, the server and the title. |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Example: |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
{ |
|
93
|
|
|
|
|
|
|
'dns_aaaa' => '2400:cb00:2048:1::6814:e42a', |
|
94
|
|
|
|
|
|
|
'server' => 'cloudflare', |
|
95
|
|
|
|
|
|
|
'title' => 'EPFL news' |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
or |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
{'dns_aaaa' => 'null', 'error' => 'no AAAA record'} |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub getWebServer { |
|
105
|
4
|
|
|
4
|
1
|
2307
|
my $domain = shift; |
|
106
|
4
|
100
|
|
|
|
11
|
return if not defined $domain; |
|
107
|
|
|
|
|
|
|
|
|
108
|
3
|
|
|
|
|
7
|
return p_getWebAPI( $WEB_SERVER, $domain, 1 ); |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head2 getWebDns( $domain ) |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Return DNS servers. |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Example: |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
{'dns_ok' => 1, 'dns_servers' => ['stisun1.epfl.ch', 'stisun2.epfl.ch']} |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
or |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
{'dns_ok' => 0, 'dns_servers' => []} |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=cut |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub getWebDns { |
|
126
|
4
|
|
|
4
|
1
|
8079
|
my $domain = shift; |
|
127
|
4
|
100
|
|
|
|
11
|
return if not defined $domain; |
|
128
|
|
|
|
|
|
|
|
|
129
|
3
|
|
|
|
|
8
|
return p_getWebAPI( $WEB_DNS, $domain, 0 ); |
|
130
|
|
|
|
|
|
|
} |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 PRIVATE SUBROUTINES/METHODS |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head2 p_getWebAPI |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Return the response from the API. |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=cut |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
sub p_getWebAPI { |
|
141
|
9
|
|
|
9
|
1
|
15
|
my ( $api, $domain, $withScheme ) = @_; |
|
142
|
|
|
|
|
|
|
|
|
143
|
9
|
|
|
|
|
17
|
my $ua = p_createUserAgent(); |
|
144
|
9
|
|
|
|
|
22
|
my $url = p_buildUrl( $api, $domain, $withScheme ); |
|
145
|
9
|
|
|
|
|
48
|
my $response = p_getUrl( $ua, $url ); |
|
146
|
9
|
100
|
|
|
|
32151
|
if ( $response->is_success ) { |
|
147
|
6
|
|
|
|
|
45
|
my $struct = from_json( $response->decoded_content ); |
|
148
|
6
|
|
|
|
|
774
|
return $struct; |
|
149
|
|
|
|
|
|
|
} |
|
150
|
3
|
|
|
|
|
75
|
return; |
|
151
|
|
|
|
|
|
|
} |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head2 p_createUserAgent |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
Return a LWP::UserAgent. |
|
156
|
|
|
|
|
|
|
LWP::UserAgent objects can be used to dispatch web requests. |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=cut |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
sub p_createUserAgent { |
|
161
|
10
|
|
|
10
|
1
|
3379
|
my $ua = LWP::UserAgent->new; |
|
162
|
|
|
|
|
|
|
|
|
163
|
10
|
|
|
|
|
5810
|
$ua->timeout($TIMEOUT); |
|
164
|
10
|
|
|
|
|
109
|
$ua->agent('IDevelopBot - v1.0.0'); |
|
165
|
10
|
|
|
|
|
501
|
$ua->env_proxy; |
|
166
|
10
|
|
|
|
|
22959
|
$ua->max_redirect($MAX_REDIRECT); |
|
167
|
|
|
|
|
|
|
|
|
168
|
10
|
|
|
|
|
83
|
return $ua; |
|
169
|
|
|
|
|
|
|
} |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head2 p_getUrl |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Dispatch a GET request on the given $url |
|
174
|
|
|
|
|
|
|
The return value is a response object. See HTTP::Response for a description |
|
175
|
|
|
|
|
|
|
of the interface it provides. |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=cut |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
sub p_getUrl { |
|
180
|
11
|
|
|
11
|
1
|
25696
|
my ( $ua, $url ) = @_; |
|
181
|
|
|
|
|
|
|
|
|
182
|
11
|
|
|
|
|
31
|
return $ua->get($url); |
|
183
|
|
|
|
|
|
|
} |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=head2 p_buildUrl |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
Return the correct url to call for the API. |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=cut |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
sub p_buildUrl { |
|
192
|
2
|
|
|
2
|
1
|
63
|
my ( $path, $domain, $withScheme ) = @_; |
|
193
|
|
|
|
|
|
|
|
|
194
|
2
|
|
|
|
|
5
|
my $url = $path . '?url=' . $domain; |
|
195
|
2
|
100
|
|
|
|
6
|
if ($withScheme) { |
|
196
|
1
|
|
|
|
|
2
|
$url .= '&scheme=http'; |
|
197
|
|
|
|
|
|
|
} |
|
198
|
2
|
|
|
|
|
7
|
return $url; |
|
199
|
|
|
|
|
|
|
} |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=head1 AUTHOR |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
William Belle, C<< >> |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=head1 BUGS AND LIMITATIONS |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
Please report any bugs or feature requests here |
|
208
|
|
|
|
|
|
|
L. |
|
209
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
|
210
|
|
|
|
|
|
|
your bug as I make changes. |
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=head1 SUPPORT |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
perldoc EPFL::Net::ipv6Test |
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
You can also look for information at: |
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=over 4 |
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
223
|
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
L |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
L |
|
229
|
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
=item * Search CPAN |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
L |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
=back |
|
235
|
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
237
|
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
Copyright ECOLE POLYTECHNIQUE FEDERALE DE LAUSANNE, Switzerland, VPSI, 2018. |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License"); |
|
241
|
|
|
|
|
|
|
you may not use this file except in compliance with the License. |
|
242
|
|
|
|
|
|
|
You may obtain a copy of the License at |
|
243
|
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
L |
|
245
|
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software |
|
247
|
|
|
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS, |
|
248
|
|
|
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
249
|
|
|
|
|
|
|
See the License for the specific language governing permissions and |
|
250
|
|
|
|
|
|
|
limitations under the License. |
|
251
|
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
=cut |
|
253
|
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
1; |