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

Update profile parameter "resolver.defaults.retry" #1258

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
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
13 changes: 9 additions & 4 deletions lib/Zonemaster/Engine/Nameserver.pm
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ sub _build_dns {
$res->dnssec( 0 );
$res->edns_size( $UDP_EDNS_QUERY_DEFAULT );

$res->retry( Zonemaster::Engine::Profile->effective->get( q{resolver.defaults.retry} ) );
$res->retry( Zonemaster::Engine::Profile->effective->get( q{resolver.defaults.retry} ) + 1 );
$res->retrans( Zonemaster::Engine::Profile->effective->get( q{resolver.defaults.retrans} ) );
$res->usevc( Zonemaster::Engine::Profile->effective->get( q{resolver.defaults.usevc} ) );
$res->igntc( Zonemaster::Engine::Profile->effective->get( q{resolver.defaults.igntc} ) );
Expand Down Expand Up @@ -452,7 +452,7 @@ sub _query {
);

# Make sure we have a value for each flag
$flags{q{retry}} = $href->{q{retry}} // Zonemaster::Engine::Profile->effective->get( q{resolver.defaults.retry} );
$flags{q{retry}} = $href->{q{retry}} + 1 // Zonemaster::Engine::Profile->effective->get( q{resolver.defaults.retry} ) + 1;
$flags{q{retrans}} = $href->{q{retrans}} // Zonemaster::Engine::Profile->effective->get( q{resolver.defaults.retrans} );
$flags{q{dnssec}} = $href->{q{dnssec}} // 0;
$flags{q{usevc}} = $href->{q{usevc}} // Zonemaster::Engine::Profile->effective->get( q{resolver.defaults.usevc} );
Expand Down Expand Up @@ -537,7 +537,12 @@ sub _query {
# Reset to defaults

foreach my $flag ( keys %flags ) {
$self->dns->$flag( Zonemaster::Engine::Profile->effective->get( q{resolver.defaults.}.$flag ) );
if ( $flag eq 'retry' ) {
$self->dns->$flag( Zonemaster::Engine::Profile->effective->get( q{resolver.defaults.}.$flag ) + 1 );
}
else {
$self->dns->$flag( Zonemaster::Engine::Profile->effective->get( q{resolver.defaults.}.$flag ) );
}
}

if ( $res ) {
Expand Down Expand Up @@ -864,7 +869,7 @@ Set the timeout for the outgoing sockets. May or may not be observed by the unde

=item retry

Set the number of times the query is tried.
Set the number of times a query is re-tried. This does not include the initial query.

=item igntc

Expand Down
9 changes: 5 additions & 4 deletions lib/Zonemaster/Engine/Profile.pm
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ my %profile_properties_details = (
},
q{resolver.defaults.retry} => {
type => q{Num},
min => 1,
max => 255
min => 0,
max => 254
},
q{resolver.defaults.usevc} => {
type => q{Bool}
Expand Down Expand Up @@ -681,8 +681,9 @@ This should almost certainly be kept false.

=head2 resolver.defaults.retry

An integer between 1 and 255 inclusive.
The number of times a query is sent before we give up. Default 2.
An integer between 0 and 254.
The number of times a query is re-sent before giving up. This does not include the initial query.
Default 1.

=head2 resolver.defaults.igntc

Expand Down
2 changes: 1 addition & 1 deletion share/profile.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"fallback" : true,
"recurse" : false,
"retrans" : 3,
"retry" : 2,
"retry" : 1,
"usevc" : false,
"timeout": 5
}
Expand Down
2 changes: 1 addition & 1 deletion share/profile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ resolver:
igntc: false
recurse: false
retrans: 3
retry: 2
retry: 1
timeout: 5
usevc: false
test_cases:
Expand Down
8 changes: 4 additions & 4 deletions t/profiles.t
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,8 @@ subtest 'from_json() dies on illegal values' => sub {
dies_ok { Zonemaster::Engine::Profile->from_json( '{"net":{"ipv4":1}}' ); } "checks type of net.ipv4";
dies_ok { Zonemaster::Engine::Profile->from_json( '{"net":{"ipv6":0}}' ); } "checks type of net.ipv6";
dies_ok { Zonemaster::Engine::Profile->from_json( '{"no_network":1}' ); } "checks type of no_network";
dies_ok { Zonemaster::Engine::Profile->from_json( '{"resolver":{"defaults":{"retry":0}}}' ); } "checks lower bound of resolver.defaults.retry";
dies_ok { Zonemaster::Engine::Profile->from_json( '{"resolver":{"defaults":{"retry":256}}}' ); } "checks upper bound of resolver.defaults.retry";
dies_ok { Zonemaster::Engine::Profile->from_json( '{"resolver":{"defaults":{"retry":-1}}}' ); } "checks lower bound of resolver.defaults.retry";
dies_ok { Zonemaster::Engine::Profile->from_json( '{"resolver":{"defaults":{"retry":255}}}' ); } "checks upper bound of resolver.defaults.retry";
dies_ok { Zonemaster::Engine::Profile->from_json( '{"resolver":{"defaults":{"retry":1.5}}}' ); } "checks type of resolver.defaults.retry";
dies_ok { Zonemaster::Engine::Profile->from_json( '{"resolver":{"defaults":{"retrans":0}}}' ); } "checks lower bound of resolver.defaults.retrans";
dies_ok { Zonemaster::Engine::Profile->from_json( '{"resolver":{"defaults":{"retrans":256}}}' ); } "checks upper bound of resolver.defaults.retrans";
Expand Down Expand Up @@ -546,8 +546,8 @@ subtest 'set() dies if the given property name is invalid' => sub {
subtest 'set() dies on illegal value' => sub {
my $profile = Zonemaster::Engine::Profile->new;

dies_ok { $profile->set( 'resolver.defaults.retry', 0 ); } 'checks lower bound of resolver.defaults.retry';
dies_ok { $profile->set( 'resolver.defaults.retry', 256 ); } 'checks upper bound of resolver.defaults.retry';
dies_ok { $profile->set( 'resolver.defaults.retry', -1 ); } 'checks lower bound of resolver.defaults.retry';
dies_ok { $profile->set( 'resolver.defaults.retry', 255 ); } 'checks upper bound of resolver.defaults.retry';
dies_ok { $profile->set( 'resolver.defaults.retry', 1.5 ); } 'checks type of resolver.defaults.retry';
dies_ok { $profile->set( 'resolver.defaults.retrans', 0 ); } 'checks lower bound of resolver.defaults.retrans';
dies_ok { $profile->set( 'resolver.defaults.retrans', 256 ); } 'checks upper bound of resolver.defaults.retrans';
Expand Down