Validator(3)
π¦ Validator(3) β like, the whole vibe π¦
okay so real talk, this is Validator(3), straight out of the User Contributed Perl Documentation section, and it's the manual page for the libval gateway. it's long, bestie, so we're doing this in parts β this is part 1, more is coming, don't go anywhere π
β¨ NAME β¨
Net::DNS::SEC::Validator β the interface to libval(3) plus all the related constants, structures and functions that come with it π
πΈ SYNOPSIS πΈ
here's the whole mood board, copied exactly, no cap:
use Net::DNS::SEC::Validator;
use Net::DNS::Packet;
use Net::hostent;
use Net::addrinfo;
use Socket qw(:all);
sub callback {
}
my $validator = new Net::DNS::SEC::Validator(policy => ":");
$validator.map_ns("dnssec-tools.org", "127.0.0.1");
my (@r) = $validator->getaddrinfo("good-A.test.dnssec-tools.org");
my $r = $validator->res_query("dnssec-tools.org", "IN", "MX");
my $h = $validator->gethostbyname("good-AAAA.test.dnssec-tools.org",
AF_INET6);
$validator->async_submit("badsign-a.test.dnssec-tools.org",
"IN", "A", 0, \&callback, undef);
do {
my $ref = $val->async_gather($readfds, $timeout);
my $ret = $ref->[0];
my $readfds = $ref->[1];
my $timeout = $ref->[2];
if (! @$readfds) {
last;
}
my @readyarr = IO::Select->new(@$readfds)->can_read($timeout);
$ret = $validator->async_check(\@readyarr);
} while(1);
like, look at that. it's giving "i know exactly what i'm doing" energy π₯
π DESCRIPTION π
so the Validator module gives you access to the libval(3) validating DNS resolver library β the whole thing. and it's not some clunky procedural mess either, the library functions are accessed through an object-oriented interface π
the way this interface is designed, it's literally hiding some of the complexity of validating resolvers from you. you're welcome. and if you want to customize how the application-interface behaves, you can do that through configuration files provided by libval, and it throws back extensive error codes so you know exactly what went down π«Ά
also, since Validator is basically a gateway to libval, the docs for libval have all the further details on how the Validator interfaces and parameters may be used. so like, iykyk, go read those too π
and if you're wondering about DNSSEC and the associated resolver behavior β the deets live in the core DNSSEC RFCs (4033-4035). iconic numbers, honestly β
to be continuedβ¦ more parts coming, don't touch that dial π
π INTERFACE π
okay so this module supports both synchronous and asynchronous lookups β yes bestie, she does it all. Here's the API, laid out for you:
π Validator Constructor π
This constructor builds a new validator object, and that object is what you use to make all the various resolver calls. The moment your validator object is created, a policy object gets created too. That policy object is the one handing out all the settings that control the various aspects of DNS resolution.
To create a validator object, use the Net::DNS::SEC::Validator->new() method. It takes a bunch of optional parameters, and we're about to go through every single one, don't worry π
A policy object can be named with the policy parameter β that associates a label with a particular policy, so you can reference that policy again later. If you don't specify the label, it gets the default label from the libval dnsval.conf file. Easy.
The parameters to the constructor are passed as a hash, with both key and value given in the call. Besides the policy label, there are two sets of constructor parameters, and they're separated based on how they get stored and used in libval.
πΈ Context Options πΈ
This group of parameters lives in a val_context_opt structure in libval. That structure is defined in dnssec/validator/include/validator/validator.h. The context options below are the hash-key values you use in the constructor call.
dnsval_confβ the configuration policy for the libval library.- This file contains the validator policy. The default value is
/usr/local/etc/dnssec-tools/dnsval.conf, but heads up: this may have been changed when libval was built and installed. val_context_optfield:vc_val_conf
- This file contains the validator policy. The default value is
nslistβ a list of name servers that should be used when resolving names.- This must be a white-space delimited list of IP or IPv6 addresses.
val_context_optfield:vc_nslist
polflagsβ a set of bitmapped policy flags.- The valid flags are defined in
dnssec/validator/include/validator/validator.h. The default value isCTX_DYN_POL_RES_OVR. val_context_optfield:vc_polflags
- The valid flags are defined in
qflagsβ the set of default query flags.- The valid flags are defined in
dnssec/validator/include/validator/validator.h. The default value is0. val_context_optfield:vc_qflags
- The valid flags are defined in
resolv_confβ this file contains nameserver and search options for the libval library.- The default value is
/usr/local/etc/dnssec-tools/resolv.conf, but (again, iykyk) this may have been changed when libval was built and installed. val_context_optfield:vc_res_conf
- The default value is
root_hintsβ this file contains bootstrapping information for the name resolver.- The default value is
/usr/local/etc/dnssec-tools/root.hints, but this may have been changed when libval was built and installed. val_context_optfield:vc_root_conf
- The default value is
valpolβ this supplies a customized piece of validator configuration to the default validator configuration, as an extension or an override.- This is null by default.
val_context_optfield:vc_valpol
β Global Options β
This group of parameters lives in a val_global_opt structure, which is itself stored in the gopt field of the val_context_opt structure. That structure is defined in dnssec/validator/include/validator/validator.h. The global options below are the hash-key values you use in the constructor call.
For all but the log_target field, a value of -1 means an "ignore" condition π«. What that means: the validator will not include dynamically supplied global options with a value of -1 when it creates its context. This is literally so an application can override just a subset of global options while using the global options supplied in the dnsval.conf file by default. Chef's kiss.
And even though libval uses the global options in a separate structure from the context options, they are all specified in the same hash when you pass them as parameters to the Validator constructor.
app_policyβ this field is equivalent to theenv-policyoption in adnsval.conffile. The legal values and theirenv-policyequivalences are:VAL_POL_GOPT_DISABLEβ"disable"VAL_POL_GOPT_ENABLEβ"enable"VAL_POL_GOPT_OVERRIDEβ"override"- The default value is
-1. val_global_optfield:gopt.app_policy
closest_ta_onlyβ this field is equivalent to theclosest-ta-onlyoption in adnsval.conffile.- Setting this to
1is equivalent to settingclosest-ta-onlyto"yes"; setting it to0is equivalent to"no". The default value is-1. val_global_optfield:gopt.closest_ta_only
- Setting this to
edns0_sizeβ this field is equivalent to theedns0-sizeoption in adnsval.conffile.- The default value is
-1. val_global_optfield:gopt.edns0_size
- The default value is
env_policyβ this field is equivalent to theenv-policyoption in adnsval.conffile. The legal values and theirenv-policyequivalences are:VAL_POL_GOPT_DISABLEβ"disable"VAL_POL_GOPT_ENABLEβ"enable"VAL_POL_GOPT_OVERRIDEβ"override"- The default value is
-1. val_global_optfield:gopt.env_policy
local_is_trustedβ this field is equivalent to thetrust-oob-answersoption in adnsval.conffile.- Setting this to
1is equivalent to settingtrust-oob-answersto"yes"; setting it to0is equivalent to"no". The default value is-1. val_global_optfield:gopt.local_is_trusted
- Setting this to
log_targetβ this field lets the caller specify additional log targets on top of the ones given in thednsval.conffile.- No additional logs are listed by default.
val_global_optfield:gopt.log_target
rec_fallbackβ this field is equivalent to therec-fallbackoption in adnsval.conffile.- Setting this to
1is equivalent to settingrec-fallbackto"yes"; setting it to0is equivalent to"no". The default value is-1. val_global_optfield:gopt.rec_fallback
- Setting this to
max_refreshβ this field is equivalent to themax-refreshoption in adnsval.conffile.val_global_optfield:gopt.max_refresh
protoβ this field is equivalent to theprotooption in adnsval.conffile.- Setting this value to
1is equivalent to settingprototo"ipv4"; setting this value to2is equivalent to settingprototo"ipv6". The default is0, which is equivalent to settingprototo"any". val_global_optfield:gopt.proto
- Setting this value to
timeoutβ this field is equivalent to thetimeoutoption in adnsval.conffile.val_global_optfield:gopt.timeout
retryβ this field is equivalent to theretryoption in adnsval.conffile.val_global_optfield:gopt.retry
π¦ Validator Result Fields π¦
Operation status and results are found in these validator fields, bestie:
$validator->{error} => the latest method error code
$validator->{errorStr} => the latest method error string
$validator->{valStatus} => the val_status of last call (if single)
$validator->{valStatusStr} => the val_status string of last call
Values for these fields are described in the next section π
π $validator->getaddrinfo(<name>[,<service>[,<hints>]]) π
where:
<name>β is the node name or numeric address being queried<service>β is the name or number representing the service- (note:
<name>or<service>may beundef, but not both)
- (note:
<hint>β aNet::addrinfoobject specifying flags, family, etc.
returns:
An array of Net::addrinfo objects (augmented with a 'val_status' field). On error, returns an empty array. In scalar context it returns the first Net::addrinfo object, or undef on error.
π $validator->gethostbyname(<name>[,<family>]) π
where:
<name>β is the node name or numeric address being queried<family>β the address family of the returned entry (default:AF_INET)
returns:
A Net::hostent object. The validator valStatus/valStatusStr fields will be updated. On error, undef is returned and the validator object's error/errorStr fields are updated.
π§ $validator->res_query(<name>[,<class>[,<type>]]) π§
where:
<name>β is the node name or numeric address being queried<class>β is the DNS class of the record being queried (default:IN)<type>β is the DNS record type being queried (defaultA)
returns:
A packed DNS query result is returned on success. This object is suitable to be passed to the Net::DNS::Packet(\$result) interface for parsing. The validator valStatus/valStatusStr fields will be updated. On error, undef is returned and the validator object's error/errorStr fields are updated.
π $validator->policy([<label>]) π
where:
<label>β the policy label to use (old context is destroyed β οΈ)- (default:
":"dnsval.conf default policy)
- (default:
returns:
The policy label currently (after the change) being used.
π $validator->istrusted([<val_status>]) π
where:
<val_status>β numeric validator status code- (default:
$validator->{valStatus})
- (default:
returns:
A boolean positive value if <val_status> is a trusted result. Slay.
β¨ $validator->valStatusStr([<val_status>]) β¨
where:
<val_status>β numeric validator status code- (default:
$validator->{valStatus})
- (default:
returns:
A string representation of the given <val_status>.
π«Ά $validator->map_ns(<zone>, <ipaddr>, <recursive>) π«Ά
where:
<zone>β string value for zone<ipaddr>β the IP address to which all queries associated with the above'zone'should be directed.<recursive>β if set to1, this name server is considered recursive (queries are sent with the RD bit set). The default value is to consider the name server to be authoritative.
returns:
0 if the association between the zone and the IP address could be made successfully; some other value if the association could not be created.
π§ VALIDATOR DATA FIELDS π§
okay bestie, this part is all about the data fields, and it's honestly giving "receipts" energy. π
The validator's error and errorStr fields are set with values corresponding to those from the standard herror() and hstrerror() functions. These values are defined in netdb.h. Here's the whole lineup:
error0βerrorStrResolver Error 0 (no error)error1βerrorStrUnknown hosterror2βerrorStrHost name lookup failureerror3βerrorStrUnknown server errorerror4βerrorStrNo address associated with name
The values for the validator's valStatus field are defined in .../dnssec-tools/validator/include/validator/val_errors.h. The values for the valStatusStr fields are the text representation of the status values' constants. The different possible values for valStatus are listed below, and further details are provided in libval(3):
VAL_BARE_RRSIGVAL_INDETERMINATEVAL_BOGUSVAL_DNS_ERRORVAL_IGNORE_VALIDATIONVAL_NONEXISTENT_NAMEVAL_NONEXISTENT_NAME_NOCHAINVAL_NONEXISTENT_TYPEVAL_NONEXISTENT_TYPE_NOCHAINVAL_NOTRUSTVAL_OOB_ANSWERVAL_PINSECUREVAL_PINSECURE_UNTRUSTEDVAL_SUCCESSVAL_TRUSTED_ANSWERVAL_UNTRUSTED_ANSWERVAL_UNTRUSTED_ZONEVAL_VALIDATED_ANSWER
The istrusted() and isvalidated() functions can be used to test if a particular valStatus value corresponds to a trusted or a validated status condition. β¨
π¨ bestie, this is important: status values that are neither trusted nor validated are un-trustworthy and must be treated as such by the application. no cap.
πΈ EXAMPLES πΈ
okay, here's the exact example, copy-paste energy and all β do not come for me about the formatting, I'm keeping it verbatim because that's the assignment. π«Ά
use Net::DNS::SEC::Validator;
use Net::DNS::Packet;
use Net::hostent;
use Net::addrinfo;
use Socket qw(:all);
# construct object
my $validator = new Net::DNS::SEC::Validator(policy => ":");
# change validation policy
$validator->policy("validate_tools:");
# fetch array of Net::addrinfo objects
my (@r) = $validator->getaddrinfo("good-A.test.dnssec-tools.org");
foreach $a (@r) {
print $a->stringify, " is trusted\n"
if $validator->istrusted($a->val_status));
}
# query an MX record
my $r = $validator->res_query("dnssec-tools.org", "IN", "MX");
my ($pkt, $err) = new Net::DNS::Packet(\$r);
print ($validator->istrusted ?
"result is trusted\n" :
"result is NOT trusted\n");
my $h = $validator->gethostbyname("good-A.test.dnssec-tools.org");
if ( @{$h->addr_list}) {
my $i;
for $addr ( @{$h->addr_list} ) {
printf "\taddr #%d is [%s]\n", $i++, inet_ntoa($addr);
}
}
# get details of validation
my $a = $validator->resolve_and_check("good-a.test.dnssec-tools.org", "IN", "A", 0);
foreach my $h (@$a) {
print "Status: " . ${$h}{status} . "\n";
print ($validator->istrusted(${$h}{status}) ?
"result is trusted\n" :
"result is NOT trusted\n");
$acs = ${$h}{answer};
foreach my $ac ($acs) {
print "AC status: " . ${$ac}{status} . "\n";
$acr = ${$acr}{rrset};
$acd = ${$acr}{data};
foreach $d (@$acd) {
print "Data RR status: " . ${$d}{rrstatus} . "\n";
${$d}{rrdata}->print;
}
$acs = ${$acr}{sigs};
foreach $d (@$acs) {
print "Sig RR status: " . ${$d}{rrstatus} . "\n";
${$d}{rrdata}->print;
}
}
}
wait, bestie, I need to be so fr right now β I have to keep the code exactly as the original, so the line above ${$acr}{rrset} is exactly what the original says even though my brain is screaming. we preserve, we don't "fix". periodt. π
π¦ SEE ALSO π¦
libval(3)dnsval.conf(3)resolv.conf(3)root.hints(3)
π COPYRIGHT π
Copyright (c) 2006 G. S. Marzot. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Copyright (c) 2006-2013 SPARTA, Inc. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
π AUTHOR π
G. S. Marzot (marz@users.sourceforge.net)
π and that's the whole page, bestie! brought to you by perl v5.44.0, dated 2026-10-17, and it's literally Validator(3) signing off. slay. πβ¨
π¦ where this page comes from
- arch rolling: dnssec-tools 2.2.3-16 Β· BSD
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms