-
Notifications
You must be signed in to change notification settings - Fork 22
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -147,15 +147,13 @@ has 'restore' => ( | |
has 'ipv4' => ( | ||
is => 'ro', | ||
isa => 'Bool', | ||
default => 1, | ||
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.' ), | ||
); | ||
|
@@ -358,9 +356,9 @@ 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 override the profile setting, but only if selected. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the control flow is apparent from the syntax (like I suggest below), this added clarification is unnecessary and distracting. And it's better to remove it. |
||
Zonemaster::Engine::Profile->effective->set( q{net.ipv4}, 0+$self->ipv4 ) if defined ($self->ipv4); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That "else" should first check if any of ipv4/ipv6 is enabled, if not set both. Otherwise we will, again, override the setting in any selected config file. I will check and come with an updated version. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh yes I didn't see that it was as twisted as that. I think this cumbersome code covers every cases (maybe some perl magic might make it lighter)
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will also be wrong, because if you have selected a profile where IPv6 has been disabled, then your suggestion will enable IPv6 unless you explicitly have selected --no-ipv6. I will proved an update. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is really twisted ^^. I'll let you find a solution ;) |
||
Zonemaster::Engine::Profile->effective->set( q{net.ipv6}, 0+$self->ipv6 ) if defined ($self->ipv6); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you update this to use I do realize there are a couple of instances of trailing if statements in this file, but adding more of them is a mistake from a readability point of view. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is that only your personal opinion that trailing "if" is always less readable, or do you know of any studies of that supports that? In that case we get three lines, instead of one, and more separators. And the condition is short. |
||
|
||
|
||
if ( $self->dump_profile ) { | ||
|
There was a problem hiding this comment.
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 :
I feel an
else
statement is needed in the code to enable IPv4 and IPv6 by default.There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
Should CLI be helpful in that case?