Skip to content

Commit

Permalink
Update after review - refactoring, documentation
Browse files Browse the repository at this point in the history
Deprecate Profile settings "dnssec" and "edns_size" - changing their value will now have no effect. Planned for complete removal in 2023.2.

Added new constant UDP_EDNS_QUERY_DEFAULT

Restore 'edns_size' previous value in profile.json
  • Loading branch information
tgreenx committed Apr 18, 2023
1 parent cbaaad2 commit 041271b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 16 deletions.
14 changes: 11 additions & 3 deletions lib/Zonemaster/Engine/Constants.pm
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ our @EXPORT_OK = qw[
$MINIMUM_NUMBER_OF_NAMESERVERS
$RESOLVER_SOURCE_OS_DEFAULT
$UDP_PAYLOAD_LIMIT
$UDP_EDNS_QUERY_DEFAULT
$UDP_COMMON_EDNS_LIMIT
@IPV4_SPECIAL_ADDRESSES
@IPV6_SPECIAL_ADDRESSES
Expand All @@ -56,7 +57,7 @@ our %EXPORT_TAGS = (
soa => [
qw($DURATION_5_MINUTES_IN_SECONDS $DURATION_1_HOUR_IN_SECONDS $DURATION_4_HOURS_IN_SECONDS $DURATION_12_HOURS_IN_SECONDS $DURATION_1_DAY_IN_SECONDS $DURATION_1_WEEK_IN_SECONDS $DURATION_180_DAYS_IN_SECONDS $SERIAL_BITS $SERIAL_MAX_VARIATION)
],
misc => [qw($UDP_PAYLOAD_LIMIT $UDP_COMMON_EDNS_LIMIT $MINIMUM_NUMBER_OF_NAMESERVERS $RESOLVER_SOURCE_OS_DEFAULT $BLACKLISTING_ENABLED)]
misc => [qw($UDP_PAYLOAD_LIMIT $UDP_EDNS_QUERY_DEFAULT $UDP_COMMON_EDNS_LIMIT $MINIMUM_NUMBER_OF_NAMESERVERS $RESOLVER_SOURCE_OS_DEFAULT $BLACKLISTING_ENABLED)]
, # everyting in %EXPORT_OK that isn't included in any of the other tags
addresses => [qw(@IPV4_SPECIAL_ADDRESSES @IPV6_SPECIAL_ADDRESSES)],
);
Expand Down Expand Up @@ -93,8 +94,9 @@ Readonly our $RESOLVER_SOURCE_OS_DEFAULT => 'os_default';
Readonly our $SERIAL_BITS => 32;
Readonly our $SERIAL_MAX_VARIATION => 0;

Readonly our $UDP_PAYLOAD_LIMIT => 512;
Readonly our $UDP_COMMON_EDNS_LIMIT => 4_096;
Readonly our $UDP_PAYLOAD_LIMIT => 512;
Readonly our $UDP_EDNS_QUERY_DEFAULT => 512;
Readonly our $UDP_COMMON_EDNS_LIMIT => 4_096;

Readonly::Array our @IPV4_SPECIAL_ADDRESSES => _extract_iana_ip_blocks($IP_VERSION_4);

Expand Down Expand Up @@ -282,6 +284,12 @@ C<$UDP_PAYLOAD_LIMIT>
=item *
C<$UDP_EDNS_QUERY_DEFAULT>
An integer, used to define the EDNS0 UDP packet size in EDNS queries.
=item *
C<UDP_COMMON_EDNS_LIMIT>
=item *
Expand Down
23 changes: 11 additions & 12 deletions lib/Zonemaster/Engine/Nameserver.pm
Original file line number Diff line number Diff line change
Expand Up @@ -212,16 +212,17 @@ sub _build_dns {
my ( $self ) = @_;

my $res = Zonemaster::LDNS->new( $self->address->ip );

$res->recurse( 0 );
$res->dnssec( 0 );
$res->edns_size( $UDP_EDNS_QUERY_DEFAULT );

$res->retry( Zonemaster::Engine::Profile->effective->get( q{resolver.defaults.retry} ) );
$res->retrans( Zonemaster::Engine::Profile->effective->get( q{resolver.defaults.retrans} ) );
$res->dnssec( Zonemaster::Engine::Profile->effective->get( q{resolver.defaults.dnssec} ) );
$res->usevc( Zonemaster::Engine::Profile->effective->get( q{resolver.defaults.usevc} ) );
$res->igntc( Zonemaster::Engine::Profile->effective->get( q{resolver.defaults.igntc} ) );
$res->recurse( Zonemaster::Engine::Profile->effective->get( q{resolver.defaults.recurse} ) );
$res->debug( Zonemaster::Engine::Profile->effective->get( q{resolver.defaults.debug} ) );
$res->edns_size( Zonemaster::Engine::Profile->effective->get( q{resolver.defaults.edns_size} ) );
$res->timeout( Zonemaster::Engine::Profile->effective->get( q{resolver.defaults.timeout} ) );

my $ip_version = Net::IP::XS::ip_get_version( $self->address->ip );
Expand Down Expand Up @@ -268,10 +269,10 @@ sub query {
);

my $class = $href->{class} // 'IN';
my $dnssec = $href->{dnssec} // Zonemaster::Engine::Profile->effective->get( q{resolver.defaults.dnssec} );
my $dnssec = $href->{dnssec} // 0;
my $usevc = $href->{usevc} // Zonemaster::Engine::Profile->effective->get( q{resolver.defaults.usevc} );
my $recurse = $href->{recurse} // Zonemaster::Engine::Profile->effective->get( q{resolver.defaults.recurse} );
my $edns_size = $href->{edns_size} // Zonemaster::Engine::Profile->effective->get( q{resolver.defaults.edns_size} );
my $edns_size = $href->{edns_size} // $UDP_EDNS_QUERY_DEFAULT;

# Fake a DS answer
if ( $type eq 'DS' and $class eq 'IN' and $self->fake_ds->{ lc( $name ) } ) {
Expand Down Expand Up @@ -453,19 +454,17 @@ 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{retrans}} = $href->{q{retrans}} // Zonemaster::Engine::Profile->effective->get( q{resolver.defaults.retrans} );
$flags{q{dnssec}} = $href->{q{dnssec}} // Zonemaster::Engine::Profile->effective->get( q{resolver.defaults.dnssec} );
$flags{q{dnssec}} = $href->{q{dnssec}} // 0;
$flags{q{usevc}} = $href->{q{usevc}} // Zonemaster::Engine::Profile->effective->get( q{resolver.defaults.usevc} );
$flags{q{igntc}} = $href->{q{igntc}} // Zonemaster::Engine::Profile->effective->get( q{resolver.defaults.igntc} );
$flags{q{fallback}} = $href->{q{fallback}} // Zonemaster::Engine::Profile->effective->get( q{resolver.defaults.fallback} );
$flags{q{recurse}} = $href->{q{recurse}} // Zonemaster::Engine::Profile->effective->get( q{resolver.defaults.recurse} );
$flags{q{timeout}} = $href->{q{timeout}} // Zonemaster::Engine::Profile->effective->get( q{resolver.defaults.timeout} );
$flags{q{edns_size}} = $href->{q{edns_size}} // $UDP_EDNS_QUERY_DEFAULT;

if ( exists $href->{edns_details} ) {
$flags{q{dnssec}} = $href->{edns_details}{do} // $flags{q{dnssec}};
$flags{q{edns_size}} = $href->{edns_details}{size} // $href->{q{edns_size}} // Zonemaster::Engine::Profile->effective->get( q{resolver.defaults.edns_size} );
}
else {
$flags{q{edns_size}} = 0;
$flags{q{edns_size}} = $href->{edns_details}{size} // $flags{q{edns_size}};
}

# Set flags for this query
Expand Down Expand Up @@ -846,9 +845,9 @@ The retransmission interval.
=item dnssec
Set the DO flag in the query. Defaults to resolver.defaults.dnssec.
Set the DO flag in the query. Defaults to false.
Enables the query to be an EDNS query if set to true.
If set to true, it becomes an EDNS query.
Value overridden by 'edns_details->do' (if also given). More details in 'edns_details' below.
=item debug
Expand Down Expand Up @@ -881,7 +880,7 @@ If set to true, prevents a server to be black-listed on a query in case there is
=item edns_size
Set the EDNS0 UDP maximum size. Defaults to resolver.defaults.edns_size.
Set the EDNS0 UDP maximum size. Defaults to 512.
Used only when the query is an EDNS query. Does not enable on its own the query to be an EDNS query.
Value overridden by 'edns_details->size' (if also given). More details in 'edns_details' below.
Expand Down
2 changes: 2 additions & 0 deletions lib/Zonemaster/Engine/Profile.pm
Original file line number Diff line number Diff line change
Expand Up @@ -665,10 +665,12 @@ Default 3.
=head2 resolver.defaults.dnssec
*DEPRECATED as of 2023.1. Planned for removal in 2023.2*
A boolean. If true, sets the DO flag in queries. Default false.
=head2 resolver.defaults.edns_size
*DEPRECATED as of 2023.1. Planned for removal in 2023.2*
An integer. The EDNS0 UDP size used in EDNS queries. Default 512.
=head2 resolver.defaults.recurse
Expand Down
2 changes: 1 addition & 1 deletion share/profile.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"defaults" : {
"debug" : false,
"dnssec" : false,
"edns_size" : 512,
"edns_size" : 0,
"igntc" : false,
"fallback" : true,
"recurse" : false,
Expand Down

0 comments on commit 041271b

Please sign in to comment.