-
Notifications
You must be signed in to change notification settings - Fork 34
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
New "resolver.source4" and "resolver.source6" properties #1203
Conversation
The code looks fine as it is, but I don’t think we should allow |
I thought about it too, and choose not to alter the current behavior to avoid a breaking change at this stage. However I also think it would be better to separate IPv4 and IPv6. Having said that, I see several options:
With all my current work on deprecating things in different components, I like the 3. better. What do you think? |
I see one more. Introduce |
I agree with @blacksponge (although I wouldn’t mind going with suggestion number 3 from @PNAX if we feel that we are deprecating too many things at once). The behavior of |
I've updated the PR with a new "resolver.source4" property as suggested. I've marked "resolver.source" as deprecated in documentation. |
It’s better, but in the current shape, we are allowing combinations of variables that yield confusing results. For example, if Furthermore, what should we do if one of So, I suggest that we only allow |
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.
I think the solution looks fine, and deprecating old "source" is a good solution for the future. Can you update share/profile.json
from
(...)
"resolver" : {
"source": "os_default"
(...)
to
(...)
"resolver" : {
"source4": ""
"source6": ""
(...)
And then I do not think there is any reason to have it in share/profile_additional_properties.json
since that is not in addition to what is in share/profile.json
.
lib/Zonemaster/Engine/Profile.pm
Outdated
@@ -622,11 +642,26 @@ replay, set this flag to false. | |||
|
|||
=head2 resolver.source | |||
|
|||
Deprecated. Use L</resolver.source4> and L</resolver.source6>. |
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.
Maybe information on in which release it will be removed?
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.
added, I chose v2024.1.
To resolve the issue zonemaster/zonemaster-cli#315 (moved to Zonemaster-CLI) this PR is not enough. The issue asks for new options for |
Use it to pass an IPv6 source address. The "resolver.source" property can be used to pass either an IPv4 or an IPv6 source address. Hence if you want to define both, use "resolver.source" to store the IPv4 and "resolver.source6" to store the IPv6.
Use it to pass an IPv4 source address. Will replace "resolver.source".
I'd like to have the following allowed states for
By default the properties are undefined. Therefore I don't think they should be present in With that in mind do you still see your remark as a change request? |
and set its default value
@marc-vanderwal, I agree. I've tried to come up with a solution to this and die on error. However I've encountered an error based on how this module is implemented and loaded. The change I was thinking about: diff --git a/lib/Zonemaster/Engine/Profile.pm b/lib/Zonemaster/Engine/Profile.pm
index e9e445f..82f0918 100644
--- a/lib/Zonemaster/Engine/Profile.pm
+++ b/lib/Zonemaster/Engine/Profile.pm
@@ -54,7 +54,6 @@ my %profile_properties_details = (
},
q{resolver.source} => {
type => q{Str},
- default => "$RESOLVER_SOURCE_OS_DEFAULT",
test => sub {
if ( $_[0] ne $RESOLVER_SOURCE_OS_DEFAULT ) {
Net::IP::XS->new( $_[0] ) || die "Property resolver.source must be an IP address or the exact string $RESOLVER_SOURCE_OS_DEFAULT";
@@ -63,20 +62,18 @@ my %profile_properties_details = (
},
q{resolver.source4} => {
type => q{Str},
- default => "",
test => sub {
- if ( $_[0] ne '' and not Net::IP::XS::ip_is_ipv4( $_[0] ) ) {
- die "Property resolver.source4 must be an IPv4 address or the empty string";
+ if ( $_[0] and not Net::IP::XS::ip_is_ipv4( $_[0] ) ) {
+ die "Property resolver.source4 must be an IPv4 address or undefined";
}
Net::IP::XS->new( $_[0] );
}
},
q{resolver.source6} => {
type => q{Str},
- default => "",
test => sub {
- if ( $_[0] ne '' and not Net::IP::XS::ip_is_ipv6( $_[0] ) ) {
- die "Property resolver.source6 must be an IPv6 address or the empty string";
+ if ( $_[0] and not Net::IP::XS::ip_is_ipv6( $_[0] ) ) {
+ die "Property resolver.source6 must be an IPv6 address or undefined";
}
Net::IP::XS->new( $_[0] );
}
@@ -278,6 +275,7 @@ sub default {
$new->set( $property_name, $profile_properties_details{$property_name}{default} );
}
}
+ $new->check_validity;
return $new;
}
@@ -299,6 +297,14 @@ sub set {
$self->_set( q{DIRECT}, $property_name, $value );
}
+sub check_validity {
+ my ( $self ) = @_;
+ my $resolver = $self->{profile}{resolver};
+ if ( exists $resolver->{source} and ( exists $resolver->{source4} or exists $resolver->{source6} ) ) {
+ die 'Error in profile: "resolver.source" (deprecated) can\'t be used in combination with "resolver.source4" or "resolver.source6".' . "\n";
+ }
+}
+
sub _set {
my ( $self, $from, $property_name, $value ) = @_;
my $value_type = reftype($value); If I apply such change update
I'd say this comes from the fact that we load the profile at module import: So far I haven't found how to properly deal with the errors (besides loading the module in a |
There are pros and cons with both solutions. It can be helpful to see the default values. On the other hand, cutting down the profile to what is needed makes it easier to read. However, we should be consistent. Since we have the other keys in
Yes. |
If it is documented that you must not set both, and if you do, you get an error, I think it should be OK. |
Something has happened with the implementation of setting the source address. I am not sure when the change was done, but it seems to be in the last release. Before if you set a valid IPv4 address that was not configured on any interface by |
This happened with v2021.2. See zonemaster/zonemaster-cli#217. |
That seems to be correct. It was, however, not the intention that there should be no error message. The expectation was that error messages from the OS would get through. For
|
Update some message ids to report name server names and addresses together instead of separatly
Update some message ids to report name server names and addresses together instead of separately
Update some message ids to report name server names and addresses together instead of separately
Purpose
Provide new properties "resolver.source4" and "resolver.source6" to allow configuring an IPv4 and an IPv6 source address. The "resolver.source" is untouched:
Context
zonemaster/zonemaster-cli#315
Changes
How to test this PR
New unit tests are provided. They should pass.
Set "resolver.source4" and/or "resolver.source6" to a value in share/profile.json and check that these interface are correctly used when running Zonemaster.