erldns_zone_cache (erldns v7.0.0-rc5)
View SourceA cache holding all of the zone data.
Supports only a single question per request: if a request contains multiple questions, only the first question will be resolved.
Summary
Functions
Creates a new table.
Remove a zone from the cache without waiting for a response.
Remove zone RRSet
Find a zone for a given qname.
Find a zone for a given qname.
Find the SOA record for the given DNS question or zone.
Get the list of NS and glue records for the given name.
Return the record set for the given dname.
Get all records for the given type and given name.
Return current sync counter
Get a zone for the specific name.
Get all records for the given zone.
Check if the name is in a zone.
Put a name and its records into the cache, along with a SHA which can be used to determine if the zone requires updating.
Put zone RRSet
Check if the record name is in the zone.
Given a zone name, list of records, and a digest, update the zone metadata in cache.
Return a list of tuples with each tuple as a name and the version SHA for the zone.
Functions
Creates a new table.
Remove a zone from the cache without waiting for a response.
Remove zone RRSet
-spec find_zone(dns:dname()) -> erldns:zone() | {error, no_question | zone_not_found | not_authoritative}.
Find a zone for a given qname.
-spec find_zone(dns:dname(), dns:rr() | [dns:rr()]) -> erldns:zone() | {error, zone_not_found | not_authoritative}.
Find a zone for a given qname.
-spec get_authority(dns:message() | dns:dname()) -> {error, no_question} | {error, not_authoritative} | {ok, dns:authority()}.
Find the SOA record for the given DNS question or zone.
Get the list of NS and glue records for the given name.
This function will always return a list, even if it is empty.
Return the record set for the given dname.
Get all records for the given type and given name.
Return current sync counter
-spec get_zone(dns:dname()) -> erldns:zone() | {error, zone_not_found}.
Get a zone for the specific name.
This function will not attempt to resolve the dname in any way, it will simply look up the name in the underlying data store.
Get all records for the given zone.
Check if the name is in a zone.
-spec put_zone(Zone | {Name, Sha, Records} | {Name, Sha, Records, Keys}) -> ok when Zone :: erldns:zone(), Name :: dns:dname(), Sha :: binary(), Records :: [dns:rr()], Keys :: [erldns:keyset()].
Put a name and its records into the cache, along with a SHA which can be used to determine if the zone requires updating.
This function will build the necessary Zone record before inserting.
The name of each record must be the fully qualified domain name (including the zone part).
Here's an example:
erldns_zone_cache:put_zone({
<<"example.com">>, <<"someDigest">>, [
#dns_rr{
name = <<"example.com">>,
type = ?DNS_TYPE_A,
ttl = 3600,
data = #dns_rrdata_a{ip = {1,2,3,4}}
},
#dns_rr{
name = <<"www.example.com">>,
type = ?DNS_TYPE_CNAME,
ttl = 3600,
data = #dns_rrdata_cname{dname = <<"example.com">>}
}
]}).
-spec put_zone_rrset(RRSet, RRFqdn, Type, Counter) -> ok | {error, term()} when RRSet :: {dns:dname(), binary(), [dns:rr()]} | {dns:dname(), binary(), [dns:rr()], [term()]}, RRFqdn :: dns:dname(), Type :: dns:type(), Counter :: integer().
Put zone RRSet
Check if the record name is in the zone.
Will also return true if a wildcard is present at the node.
-spec update_zone_records_and_digest(dns:dname(), integer(), binary()) -> ok | {error, Reason :: term()}.
Given a zone name, list of records, and a digest, update the zone metadata in cache.
Return a list of tuples with each tuple as a name and the version SHA for the zone.