aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.PL2
-rwxr-xr-xacmeman34
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
@@ -28,13 +28,13 @@ my %makefile_args = (
28 'LWP::UserAgent' => 6.05, 28 'LWP::UserAgent' => 6.05,
29 'LWP::Protocol::https' => 6.04, 29 'LWP::Protocol::https' => 6.04,
30 'Pod::Usage' => 1.51, 30 'Pod::Usage' => 1.51,
31 'Pod::Man' => 2.25, 31 'Pod::Man' => 2.25,
32 'Text::ParseWords' => 3.27, 32 'Text::ParseWords' => 3.27,
33 'Data::Dumper' => 0, 33 'Data::Dumper' => 0,
34 'Net::DNS' => 0.68, 34 'Socket' => 0,
35 'Sys::Hostname' => 1.16 35 'Sys::Hostname' => 1.16
36 }, 36 },
37 37
38 MIN_PERL_VERSION => 5.006, 38 MIN_PERL_VERSION => 5.006,
39 META_MERGE => { 39 META_MERGE => {
40 'meta-spec' => { version => 2 }, 40 'meta-spec' => { version => 2 },
diff --git a/acmeman b/acmeman
index 143ef43..0a51cdb 100755
--- a/acmeman
+++ b/acmeman
@@ -26,13 +26,13 @@ use Crypt::OpenSSL::RSA;
26use Crypt::OpenSSL::X509; 26use Crypt::OpenSSL::X509;
27use File::Basename; 27use File::Basename;
28use File::Path qw(make_path); 28use File::Path qw(make_path);
29use DateTime::Format::Strptime; 29use DateTime::Format::Strptime;
30use LWP::UserAgent; 30use LWP::UserAgent;
31use LWP::Protocol::https; 31use LWP::Protocol::https;
32use Net::DNS; 32use Socket qw(inet_ntoa);
33use Sys::Hostname; 33use Sys::Hostname;
34use Pod::Usage; 34use Pod::Usage;
35use Pod::Man; 35use Pod::Man;
36use Getopt::Long qw(:config gnu_getopt no_ignore_case); 36use Getopt::Long qw(:config gnu_getopt no_ignore_case);
37use POSIX qw(strftime time floor); 37use POSIX qw(strftime time floor);
38use App::Acmeman::Config; 38use App::Acmeman::Config;
@@ -931,45 +931,19 @@ sub coalesce {
931 } 931 }
932 @{$ref} = map { $_->{domain} } sort { $a->{ord} <=> $b->{ord} } @domlist; 932 @{$ref} = map { $_->{domain} } sort { $a->{ord} <=> $b->{ord} } @domlist;
933} 933}
934 934
935sub resolve { 935sub resolve {
936 my $host = shift; 936 my $host = shift;
937 state $res; 937 if (my @addrs = gethostbyname($host)) {
938 unless ($res) { 938 return map { inet_ntoa($_) } @addrs[4 .. $#addrs];
939 $res = new Net::DNS::Resolver();
940 }
941 my $q = $res->query($host,'ANY');
942 unless ($q) {
943 if ($res->errorstring eq 'NXDOMAIN') {
944 debug(1, "$host: no such host");
945 } elsif ($res->errorstring eq 'NOERROR') {
946 debug(1, "$host: no A record");
947 } else { 939 } else {
948 error("$host: " . $res->errorstring); 940 error("$host doesn't resolve");
949 # FIXME: bail out?
950 } 941 }
951 return (); 942 return ();
952} 943}
953 my %res;
954 my %cnames;
955 my @answer = $q->answer();
956 while (my $ans = shift @answer) {
957 if ($ans->type eq 'A') {
958 $res{$ans->rdatastr} = 1;
959 } elsif ($ans->type eq 'CNAME') {
960 unless ($cnames{$ans->cname}) { # Avoid eventual loops
961 $cnames{$ans->cname} = 1;
962 if (my $q = $res->query($ans->cname, 'A')) {
963 push @answer, ($q->answer());
964 }
965 }
966 }
967 }
968 keys %res;
969}
970 944
971sub myip { 945sub myip {
972 my $host = shift; 946 my $host = shift;
973 state $ips; 947 state $ips;
974 unless ($ips) { 948 unless ($ips) {
975 $ips = {}; 949 $ips = {};

Return to:

Send suggestions and report system problems to the System administrator.