#!/usr/bin/perl -w use strict; use warnings; use v5.14; die "usage : cat website_list.txt | ./$0 > page.html" if @ARGV != 0; my @tab; my %dom; sub get_urls { while(<>) { chomp; last if $_ eq ""; if(m#/#) { $_ =~ s#https?://##; @tab = split '/', $_; $_ = $tab[0]; } # securité @tab = split ';', $_; $_ = $tab[0]; m/^([0-9a-zA-Z\.-]+)/; $_ = $1; $dom{$_} = 0; } } sub test_ipv6 { my $domain = shift; my $ret = `/usr/bin/dig +short AAAA $domain`; if(not length $ret) { # no ipv6 ? check www.$domain $ret = `/usr/bin/dig +short AAAA www.$domain`; } if(length $ret != 0) { # there is at least an IPv6 configured chomp $ret; my @var = split "\n", $ret; for(@var) { next unless /:/; chomp; say; # print the IPv6 # we try to reach the website's server my $retping = `/bin/ping6 -i 0.5 -c 2 $_ | grep ' 0% packet loss'`; chomp $retping; if(length $retping) { $dom{$domain}++; } } } } sub check_reachability { say ''; } sub do_html { my @passed = grep { $dom{$_} } keys %dom; my @notpassed = grep { not $dom{$_} } keys %dom; say '
'; say "", join(', ', @passed), "
"; say "", join(', ', @notpassed), "
"; say ""; } get_urls; check_reachability; do_html;