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 | 38 |
2 files changed, 7 insertions, 33 deletions
diff --git a/Makefile.PL b/Makefile.PL index 53ed39a..1fad0ba 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -10,49 +10,49 @@ my %makefile_args = ( ABSTRACT_FROM => 'acmeman', VERSION_FROM => 'acmeman', AUTHOR => 'Sergey Poznyakoff <gray@gnu.org>', LICENSE => 'gpl_3', EXE_FILES => [ 'acmeman' ], PREREQ_PM => { 'Getopt::Long' => 2.34, 'File::Path' => 2.08, 'File::Basename' => 2.84, 'Test::NoWarnings' => 0, 'Crypt::RSA::Parse' => 0.043, 'Protocol::ACME' => 1.01, 'Protocol::ACME::Challenge::LocalFile' => 1.01, 'Crypt::Format' => 0.06, 'Crypt::OpenSSL::PKCS10' => 0.16, 'Crypt::OpenSSL::RSA' => 0.28, 'Crypt::OpenSSL::X509' => 1.804, 'DateTime::Format::Strptime' => 1.42, 'LWP::UserAgent' => 6.05, 'LWP::Protocol::https' => 6.04, 'Pod::Usage' => 1.51, 'Pod::Man' => 2.25, 'Text::ParseWords' => 3.27, 'Data::Dumper' => 0, - 'Net::DNS' => 0.68, + 'Socket' => 0, 'Sys::Hostname' => 1.16 }, MIN_PERL_VERSION => 5.006, META_MERGE => { 'meta-spec' => { version => 2 }, resources => { repository => { type => 'git', url => 'git://git.gnu.org.ua/gsc/acmeman.git', web => 'http://git.gnu.org.ua/cgit/gsc/acmeman.git/', }, }, provides => Module::Metadata->provides(version => '1.4', dir => 'lib') } ); my $no_autoinstall; GetOptions('no-autoinstall|N' => \$no_autoinstall) or exit(1); unless ($no_autoinstall) { require ExtUtils::AutoInstall; ExtUtils::AutoInstall->import(-core => $makefile_args{PREREQ_PM}); delete $makefile_args{PREREQ_PM}; @@ -8,49 +8,49 @@ eval 'exec perl -x -wS $0 ${1+"$@"}' # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. use strict; use feature 'state'; use Protocol::ACME; use Protocol::ACME::Challenge::LocalFile; use Crypt::Format; use Crypt::OpenSSL::PKCS10 qw(:const); 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; use App::Acmeman::Domain qw(:files); use Data::Dumper; use Text::ParseWords; our $VERSION = '1.05'; =head1 NAME App::Acmeman - manages ACME certificates =head1 SYNOPSIS B<acmeman> [B<-Fadns>] [B<-D> I<N>] [B<-f> I<FILE>] [B<--alt-names>] [B<--config-file=>I<FILE>] @@ -913,80 +913,54 @@ sub initial_setup { } } exit(EX_OK); } sub coalesce { my $ref = shift; debug(2, "coalescing virtual hosts"); my $i = 0; my @domlist; foreach my $ent (sort { $a->{domain} cmp $b->{domain} } map { { ord => $i++, domain => $_ } } @{$ref}) { if (@domlist && $domlist[-1]->{domain}->cn eq $ent->{domain}->cn) { $domlist[-1]->{domain} += $ent->{domain}; } else { push @domlist, $ent; } } @{$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) { $ips = {}; my $addhost; if ($config->isset(qw(core my-ip))) { $addhost = 0; foreach my $ip ($config->get(qw(core my-ip))) { if ($ip eq '$hostip') { $addhost = 1; } else { $ips->{$ip} = 1; } } } else { $addhost = 1; } if ($addhost) { foreach my $ip (resolve(hostname())) { |