summaryrefslogtreecommitdiffabout
path: root/acmeman
Side-by-side diff
Diffstat (limited to 'acmeman') (more/less context) (ignore whitespace changes)
-rwxr-xr-xacmeman38
1 files changed, 6 insertions, 32 deletions
diff --git a/acmeman b/acmeman
index 143ef43..0a51cdb 100755
--- a/acmeman
+++ b/acmeman
@@ -26,13 +26,13 @@ use Crypt::OpenSSL::RSA;
use Crypt::OpenSSL::X509;
use File::Basename;
use File::Path qw(make_path);
use DateTime::Format::Strptime;
use LWP::UserAgent;
use LWP::Protocol::https;
-use Net::DNS;
+use Socket qw(inet_ntoa);
use Sys::Hostname;
use Pod::Usage;
use Pod::Man;
use Getopt::Long qw(:config gnu_getopt no_ignore_case);
use POSIX qw(strftime time floor);
use App::Acmeman::Config;
@@ -931,44 +931,18 @@ sub coalesce {
}
@{$ref} = map { $_->{domain} } sort { $a->{ord} <=> $b->{ord} } @domlist;
}
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");
- } else {
- error("$host: " . $res->errorstring);
- # FIXME: bail out?
- }
- return ();
- }
- 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());
- }
- }
- }
+ if (my @addrs = gethostbyname($host)) {
+ return map { inet_ntoa($_) } @addrs[4 .. $#addrs];
+ } else {
+ error("$host doesn't resolve");
}
- keys %res;
+ return ();
}
sub myip {
my $host = shift;
state $ips;
unless ($ips) {

Return to:

Send suggestions and report system problems to the System administrator.