« blib/lib/File/Slurp/Remote/SmartOpen.pm
↑ Summary
blib/lib/File/Slurp/Remote/CanonicalHostnames.pm »
| 1 | |||||||||||
| 2 | package File::Slurp::Remote::BrokenDNS; | ||||||||||
| 3 | |||||||||||
| 4 | 3 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 3 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 3 | ▶ | use Tie::Function::Examples qw(%q_shell); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 3 | ▶ | use Socket; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 3 | ▶ | use Sys::Hostname::FQDN qw(fqdn); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 3 | require Exporter; | |||||||||
| 10 | |||||||||||
| 11 | 3 | our @ISA = qw(Exporter); | |||||||||
| 12 | 3 | our @EXPORT_OK = qw($myfqdn %fqdnify); | |||||||||
| 13 | 3 | our $VERSION = '0.48'; | |||||||||
| 14 | |||||||||||
| 15 | 3 | our %cache; | |||||||||
| 16 | 3 | our $myfqdn; | |||||||||
| 17 | 3 | our %fqdnify; | |||||||||
| 18 | |||||||||||
| 19 | 3 | ▶ | 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=3 SCAR=24.8
| |||||||||||
| 24 | 0 | my ($host) = @_; | |||||||||
| 25 | 0 | ▶ | return $cache{$host} if $cache{$host}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | 0 | ▶ | return $host if $host =~ /^-/; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 27 | 0 | my $hn = `ssh -o StrictHostKeyChecking=no -n $q_shell{$host} hostname`; | |||||||||
| 28 | 0 | chomp($hn); | |||||||||
| 29 | 0 | return $cache{$host} = $hn; | |||||||||
| 30 | 0 | }; | |||||||||
| 31 | } else { | ||||||||||
| 32 | 3 | $myfqdn = fqdn(); | |||||||||
| 33 | |||||||||||
| 34 | tie %fqdnify, 'Tie::Function::Examples', | ||||||||||
| 35 | 8 | ▶ | sub { | ||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=24.2
| |||||||||||
| 36 | 8 | my ($host) = @_; | |||||||||
| 37 | 8 | ▶ | return $cache{$host} if $cache{$host}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 38 | 0 | my $iaddr = gethostbyname($host); | |||||||||
| 39 | 0 | ▶ | return $host unless defined $iaddr; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 40 | 0 | my $name = gethostbyaddr($iaddr, AF_INET); | |||||||||
| 41 | 0 | ▶ | return $host unless defined $name; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 42 | 0 | return $cache{$host} = $name; | |||||||||
| 43 | 3 | }; | |||||||||
| 44 | } | ||||||||||
| 45 | |||||||||||
| 46 | 3 | 1; | |||||||||
| 47 | |||||||||||
| 48 | __END__ | ||||||||||