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

Updates the ipv4 and ipv6 command line options #185

Merged
merged 4 commits into from
Jan 20, 2021
Merged
Changes from all commits
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
12 changes: 7 additions & 5 deletions lib/Zonemaster/CLI.pm
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,13 @@ has 'restore' => (
has 'ipv4' => (
is => 'ro',
isa => 'Bool',
default => 1,
Copy link

Choose a reason for hiding this comment

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

This default behavior is not moved into the code. I mean, before the change if you do not have the net stanza in the profile file and you just run the CLI, IPv4 and IPv6 will be enabled by default.

Here with the current changes, removing the stanza from the profile file gives a CRITICAL message :

   0.01 CRITICAL  Both IPv4 and IPv6 are disabled.

I feel an else statement is needed in the code to enable IPv4 and IPv6 by default.

Copy link
Contributor Author

@matsduf matsduf Jan 20, 2021

Choose a reason for hiding this comment

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

Good catch. I had to remove that "default" to make it possible to detect if the option had been actively set or not. It is more complex than I thought.

Copy link
Contributor Author

@matsduf matsduf Jan 20, 2021

Choose a reason for hiding this comment

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

Now I see what you mean. If the default profile.json does not have any IPv4 or IPv6 enabled, then there will no network enabled. -- In Backend both are enabled if both are disabled.

You will get the same effect if you run

# zonemaster-cli --level INFO --test basic iis.se --no-ipv6 --no-ipv4

Should CLI be helpful in that case?

documentation =>
__( 'Flag to permit or deny queries being sent via IPv4. --ipv4 permits IPv4 traffic, --no-ipv4 forbids it.' ),
);

has 'ipv6' => (
is => 'ro',
isa => 'Bool',
default => 1,
documentation =>
__( 'Flag to permit or deny queries being sent via IPv6. --ipv6 permits IPv6 traffic, --no-ipv6 forbids it.' ),
);
Expand Down Expand Up @@ -358,9 +356,13 @@ sub run {
}

# These two must come after any profile from command line has been loaded
# to override the profile setting
Zonemaster::Engine::Profile->effective->set( q{net.ipv4}, 0+$self->ipv4 );
Zonemaster::Engine::Profile->effective->set( q{net.ipv6}, 0+$self->ipv6 );
# to make any IPv4/IPv6 option override the profile setting.
if ( defined ($self->ipv4) ) {
Zonemaster::Engine::Profile->effective->set( q{net.ipv4}, 0+$self->ipv4 );
}
if ( defined ($self->ipv6) ) {
Zonemaster::Engine::Profile->effective->set( q{net.ipv6}, 0+$self->ipv6 );
}


if ( $self->dump_profile ) {
Expand Down