summaryrefslogtreecommitdiffstats
path: root/lib/ASM/Util.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ASM/Util.pm')
-rw-r--r--lib/ASM/Util.pm12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/ASM/Util.pm b/lib/ASM/Util.pm
index dc10d64..55c49ab 100644
--- a/lib/ASM/Util.pm
+++ b/lib/ASM/Util.pm
@@ -7,6 +7,7 @@ use strict;
use Term::ANSIColor qw (:constants);
use Socket qw( inet_aton inet_ntoa );
use Data::Dumper;
+use Net::DNS 0.55 qw(rrsort);
no if $] >= 5.017011, warnings => 'experimental::smartmatch';
@@ -245,12 +246,17 @@ sub stripResp
my @answer = $response->answer;
if ($response->{header}->{rcode} ne "NOERROR") {
dprint($module, Dumper($response), 'dns');
- return;
+ return undef;
}
- if ((!(@answer)) || ($answer[0]->{type} ne 'A')) {
+ if (!(@answer)) {
return undef;
}
- return dottedQuadToInt($module, $answer[0]->{address});
+ my @addresses = rrsort('A', @answer);
+ my @results = ();
+ foreach my $address (@addresses) {
+ push @results, dottedQuadToInt($module, $address->{address});
+ }
+ return @results;
}
sub getHostIPFast