Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop dependency on Net::Interface #217

Merged
merged 2 commits into from
Oct 27, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
25 changes: 5 additions & 20 deletions docs/Installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down
40 changes: 6 additions & 34 deletions lib/Zonemaster/CLI.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest adding "This option is rarely needed."

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see when that would be useful. But I'll add sourceaddr to the POD.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see when that would be useful.

The proposed text is to further prevent users from using the option. It is really for special cases.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I expect that the people who use this option are exactly the ones who need it. Even without such an assertion.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cannot see the problem of adding extra comment.

),
);

has 'elapsed' => (
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down