| 1 | |||||||||||
| 2 | package File::Slurp::Remote::BrokenDNS; | ||||||||||
| 3 | |||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use Tie::Function::Examples; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use Socket; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 1 | ▶ | use Sys::Hostname::FQDN qw(fqdn); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 1 | require Exporter; | |||||||||
| 10 | |||||||||||
| 11 | 1 | our @ISA = qw(Exporter); | |||||||||
| 12 | 1 | our @EXPORT_OK = qw($myfqdn %fqdnify); | |||||||||
| 13 | 1 | our $VERSION = 0.2; | |||||||||
| 14 | |||||||||||
| 15 | 1 | our %cache; | |||||||||
| 16 | 1 | our $myfqdn; | |||||||||
| 17 | 1 | our %fqdnify; | |||||||||
| 18 | |||||||||||
| 19 | 1 | ▶ | if ($ENV{BROKEN_DNS_WORKAROUND}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 20 | 0 | $myfqdn = `hostname`; | |||||||||
| 21 | 0 | chomp($myfqdn); | |||||||||
| 22 | tie %fqdnify, 'Tie::Function::Examples', | ||||||||||
| 23 | 0 | ▶ | sub { | ||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||
| 24 | 0 | my ($host) = @_; | |||||||||
| 25 | 0 | ▶ | return $cache{$host} if $cache{$host}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | 0 | my $hn = `ssh -o StrictHostKeyChecking=no $host -n hostname`; | |||||||||
| 27 | 0 | chomp($hn); | |||||||||
| 28 | 0 | return $cache{$host} = $hn; | |||||||||
| 29 | 0 | }; | |||||||||
| 30 | } else { | ||||||||||
| 31 | 1 | $myfqdn = fqdn(); | |||||||||
| 32 | |||||||||||
| 33 | tie %fqdnify, 'Tie::Function::Examples', | ||||||||||
| 34 | 0 | ▶ | sub { | ||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||
| 35 | 0 | my ($host) = @_; | |||||||||
| 36 | 0 | ▶ | return $cache{$host} if $cache{$host}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 37 | 0 | my $iaddr = gethostbyname($host); | |||||||||
| 38 | 0 | ▶ | return $host unless defined $iaddr; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 39 | 0 | my $name = gethostbyaddr($iaddr, AF_INET); | |||||||||
| 40 | 0 | ▶ | return $host unless defined $name; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | 0 | return $cache{$host} = $name; | |||||||||
| 42 | 1 | }; | |||||||||
| 43 | } | ||||||||||
| 44 | |||||||||||
| 45 | 1 | 1; | |||||||||
| 46 | |||||||||||
| 47 | __END__ | ||||||||||