diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2018-05-07 12:30:32 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2018-05-07 12:30:32 +0300 |
commit | c4e539cf7b31c8938ea471419e42f79a87cfb4ea (patch) | |
tree | 91871e9ab571886deb471241adbf06b454c8f0dd | |
parent | 95c82ca2a5562e60463a38519157ae1a8b60ac1a (diff) | |
download | acmeman-c4e539cf7b31c8938ea471419e42f79a87cfb4ea.tar.gz acmeman-c4e539cf7b31c8938ea471419e42f79a87cfb4ea.tar.bz2 |
Use gethostbyname + Socket::inet_ntoa instead of Net::DNS
-rw-r--r-- | Makefile.PL | 2 | ||||
-rwxr-xr-x | acmeman | 34 |
2 files changed, 5 insertions, 31 deletions
diff --git a/Makefile.PL b/Makefile.PL index 53ed39a..1fad0ba 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -33,3 +33,3 @@ my %makefile_args = ( 'Data::Dumper' => 0, - 'Net::DNS' => 0.68, + 'Socket' => 0, 'Sys::Hostname' => 1.16 @@ -31,3 +31,3 @@ use LWP::UserAgent; use LWP::Protocol::https; -use Net::DNS; +use Socket qw(inet_ntoa); use Sys::Hostname; @@ -936,15 +936,6 @@ sub resolve { my $host = shift; - state $res; - unless ($res) { - $res = new Net::DNS::Resolver(); - } - my $q = $res->query($host,'ANY'); - unless ($q) { - if ($res->errorstring eq 'NXDOMAIN') { - debug(1, "$host: no such host"); - } elsif ($res->errorstring eq 'NOERROR') { - debug(1, "$host: no A record"); + if (my @addrs = gethostbyname($host)) { + return map { inet_ntoa($_) } @addrs[4 .. $#addrs]; } else { - error("$host: " . $res->errorstring); - # FIXME: bail out? + error("$host doesn't resolve"); } @@ -952,19 +943,2 @@ sub resolve { } - my %res; - my %cnames; - my @answer = $q->answer(); - while (my $ans = shift @answer) { - if ($ans->type eq 'A') { - $res{$ans->rdatastr} = 1; - } elsif ($ans->type eq 'CNAME') { - unless ($cnames{$ans->cname}) { # Avoid eventual loops - $cnames{$ans->cname} = 1; - if (my $q = $res->query($ans->cname, 'A')) { - push @answer, ($q->answer()); - } - } - } - } - keys %res; -} |