Subversion Repositories sysadmin_scripts

Rev

Rev 138 | Rev 157 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 138 Rev 139
Line 173... Line 173...
173
# note that $dns is an instance of Net::DNS
173
# note that $dns is an instance of Net::DNS
174
# if it is not set, will revert to using inet_aton, which only
174
# if it is not set, will revert to using inet_aton, which only
175
# works off of the resolv.conf on the local machine
175
# works off of the resolv.conf on the local machine
176
sub getHostName {
176
sub getHostName {
177
   my ($dns, $ip ) = @_;
177
   my ($dns, $ip ) = @_;
-
 
178
   return '' unless $ip;
178
   if ( $dns ) {
179
   if ( $dns ) {
179
      foreach my $resource ( @$dns ) {
180
      foreach my $resource ( @$dns ) {
180
         my  $reply = $resource->search( $ip );
181
         my  $reply = $resource->search( $ip );
181
         next unless defined $reply;
182
         next unless defined $reply;
182
         my @answer = grep { ! /^((;.*)|(\s*))$/ } split( "\n", $reply->string );
183
         my @answer = grep { ! /^((;.*)|(\s*))$/ } split( "\n", $reply->string );
Line 481... Line 482...
481
   $saveFile = \%{ $yaml->[0] };
482
   $saveFile = \%{ $yaml->[0] };
482
}
483
}
483
 
484
 
484
 
485
 
485
my $dnsResource = 0;
486
my $dnsResource = 0;
486
eval {
-
 
487
   use Net::DNS; # dns lookup, apt install libnet-dns-perl
487
eval "use Net::DNS;"; # dns lookup, apt install libnet-dns-perl
-
 
488
if ( $@ ) {
-
 
489
   $dnsResource = 0;
-
 
490
} else {
488
   $dnsResource = [];
491
   $dnsResource = [];
489
   # set up one dns resource for every router we have
492
   # set up one dns resource for every router we have
490
   # too many failures when trying to define both of them at the same time
493
   # too many failures when trying to define both of them at the same time
491
   foreach my $router ( keys %{ $config->{'routers'} } ) {
494
   foreach my $router ( keys %{ $config->{'routers'} } ) {
492
      push @$dnsResource, Net::DNS::Resolver->new(
495
      push @$dnsResource, Net::DNS::Resolver->new(