From f932404e568e95254186351e716cbf7bbdcd8dea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20P=C3=A4iv=C3=A4rinta?= Date: Tue, 12 Oct 2021 10:15:45 +0200 Subject: [PATCH 1/2] Drop dependency on Net::Interface Makes installation easier/possible on CentOS and Alpine. Results in a less helpful error message in a rare situation - i.e. when --sourceaddr is specified with an unreasonable value. --- Makefile.PL | 1 - docs/Installation.md | 25 +++++-------------------- lib/Zonemaster/CLI.pm | 40 ++++++---------------------------------- 3 files changed, 11 insertions(+), 55 deletions(-) diff --git a/Makefile.PL b/Makefile.PL index d396ea9e..701ca9ae 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -20,7 +20,6 @@ tests_recursive( 't' ); requires( 'JSON::XS' => 0, 'Locale::TextDomain' => 1.23, - 'Net::Interface' => 0, 'MooseX::Getopt' => 0, 'Text::Reflow' => 0, 'Zonemaster::Engine' => 4.002, diff --git a/docs/Installation.md b/docs/Installation.md index b6c95094..cc4758c7 100644 --- a/docs/Installation.md +++ b/docs/Installation.md @@ -45,24 +45,9 @@ This instruction covers the following operating systems: 2) Install dependencies from CPAN: - * CentOS 7: - - ```sh - sudo cpanm Net::Interface Text::Reflow - ``` - - * CentOS 8: - - ```sh - sudo cpanm Text::Reflow - curl -O https://cpan.metacpan.org/authors/id/M/MI/MIKER/Net-Interface-1.016.tar.gz - tar xf Net-Interface-1.016.tar.gz - cd Net-Interface-1.016 - ./configure - perl -I. Makefile.PL - make - sudo make install - ``` + ```sh + sudo cpanm Text::Reflow + ``` 3) Install Zonemaster::CLI @@ -93,7 +78,7 @@ This instruction covers the following operating systems: 2) Install dependencies: ```sh - sudo apt-get install libmoosex-getopt-perl libtext-reflow-perl libmodule-install-perl libnet-interface-perl + sudo apt-get install libmoosex-getopt-perl libtext-reflow-perl libmodule-install-perl ``` 3) Install Zonemaster::CLI: @@ -113,7 +98,7 @@ This instruction covers the following operating systems: 2) Install dependencies available from binary packages: ```sh - pkg install devel/gmake p5-JSON-XS p5-Locale-libintl p5-MooseX-Getopt p5-Text-Reflow p5-Net-Interface + pkg install devel/gmake p5-JSON-XS p5-Locale-libintl p5-MooseX-Getopt p5-Text-Reflow ``` 3) Install Zonemaster::CLI: diff --git a/lib/Zonemaster/CLI.pm b/lib/Zonemaster/CLI.pm index da1a2c27..ccf1f714 100755 --- a/lib/Zonemaster/CLI.pm +++ b/lib/Zonemaster/CLI.pm @@ -32,7 +32,6 @@ use List::Util qw[max]; use Text::Reflow qw[reflow_string]; use JSON::XS; use File::Slurp; -use Net::Interface; use Socket qw[AF_INET AF_INET6]; our %numeric = Zonemaster::Engine::Logger::Entry->levels; @@ -271,7 +270,10 @@ has 'sourceaddr' => ( is => 'ro', isa => 'Str', required => 0, - documentation => __( 'Local IP address that the test engine should try to send its requests from.' ), + documentation => __( + 'Source IP address used to send queries. ' + . 'Setting an IP address not correctly configured on a local network interface causes cryptic error messages.' + ), ); has 'elapsed' => ( @@ -319,12 +321,8 @@ sub run { } if ($self->sourceaddr) { - if ($self->check_sourceaddress_exists ) { - Zonemaster::Engine::Profile->effective->set( q{resolver.source}, $self->sourceaddr ); - } - else { - die __x( "Address {address} cannot be used as source address for DNS queries.\n", address => $self->sourceaddr ); - } + + Zonemaster::Engine::Profile->effective->set( q{resolver.source}, $self->sourceaddr ); } # Filehandle for diagnostics output @@ -590,32 +588,6 @@ sub run { return; } ## end sub run -sub check_sourceaddress_exists { - my ( $self ) = @_; - my $address = Zonemaster::Engine::Net::IP->new($self->sourceaddr); - my $exists = 0; - foreach my $if ( Net::Interface->interfaces() ) { - foreach my $family ( AF_INET, AF_INET6 ) { - foreach my $ifaddr ( $if->address($family) ) { - my $zm_ifaddr; - if ( $family == AF_INET ) { - $zm_ifaddr = Zonemaster::Engine::Net::IP->new(Net::Interface::inet_ntoa($ifaddr)); - } - elsif ( $family == AF_INET6 ) { - $zm_ifaddr = Zonemaster::Engine::Net::IP->new(Net::Interface::inet_ntop($ifaddr)); - } - if ( $address->short eq $zm_ifaddr->short ) { - $exists = 1; - last; - } - } - last if $exists; - } - last if $exists; - } - return $exists; -} - sub add_fake_delegation { my ( $self, $domain ) = @_; my @ns_with_no_ip; From d1db8eea77a03419905565456a14aa605d237abb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20P=C3=A4iv=C3=A4rinta?= Date: Wed, 13 Oct 2021 10:02:13 +0200 Subject: [PATCH 2/2] Add forgotten documentation --- script/zonemaster-cli | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/script/zonemaster-cli b/script/zonemaster-cli index 839ccca3..e77f1e08 100755 --- a/script/zonemaster-cli +++ b/script/zonemaster-cli @@ -182,6 +182,12 @@ then be run. The default value will be taken from the C environment variable if possible, and set to UTF-8 if not. +=item --sourceaddr=IPADDR + +Source IP address used to send queries. +Setting an IP address not correctly configured on a local network interface +causes cryptic error messages. + =back =head1 PROFILES