The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

DNS::Unbound::Result

DESCRIPTION

This class represents a DNS query result from DNS::Unbound.

ACCESSORS

This class includes an accessor for most members of struct ub_result (cf. libunbound(3)).

The following all return scalars:

  • qname(), qtype(), qclass(), ttl()

  • rcode(), nxdomain(), havedata(), canonname()

  • secure(), bogus(), why_bogus()

data() returns an array reference of strings that contain the query result in DNS-native RDATA encoding.

ADDITIONAL METHODS

$objs_ar = OBJ->to_net_dns_rrs()

The data() accessor’s return values are raw RDATA. Your application likely prefers to work with parsed DNS data, though. This method facilitates that by loading Net::DNS::RR and returning a reference to an array of instances of that class (i.e., probably a subclass of it like Net::DNS::RR::NS).

So, for example, to get a TXT query result’s value as a list of character strings, you could do:

    @cstrings = map { $_->txtdata() } @{ $result->to_net_dns_rrs() }

(NB: It might be ideal to return a single Net::DNS::Packet instance rather than the array reference, but struct ub_result doesn’t expose enough of the underlying query’s DNS details for that to make sense.)