View Source erldns_zone_cache (erldns v4.2.0)

A cache holding all of the zone data.

Write operations occur through the cache process mailbox, whereas read operations may occur either through the mailbox or directly through the underlying data store, depending on performance requirements.

Summary

Functions

Remove a zone from the cache without waiting for a response.

Find a zone for a given qname.

Find a zone for a given qname.

Find the SOA record for the given DNS question.

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.

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.

Get a zone for the specific name, including the records for the zone.

Check if the name is in a zone.

Initialize the zone cache.

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 a zone into the cache and wait for a response.

Check if the record name is in the zone. Will also return true if a wildcard is present at the node.

Start the zone cache process.

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

code_change(PreviousVersion, State, Extra)

delete_zone(Name)

-spec delete_zone(binary()) -> any().

Remove a zone from the cache without waiting for a response.

delete_zone_rrset(ZoneName, Digest, RRFqdn, Type, Counter)

-spec delete_zone_rrset(binary(), binary(), binary(), integer(), integer()) -> any().

Remove zone RRSet

find_zone(Qname)

-spec find_zone(dns:dname()) ->
                   #zone{name :: dns:dname(),
                         version :: binary(),
                         authority :: [dns:rr()],
                         record_count :: non_neg_integer(),
                         records :: [dns:rr()] | trimmed,
                         records_by_name :: #{binary() => [dns:rr()]} | trimmed,
                         records_by_type :: term(),
                         keysets :: [erldns:keyset()]} |
                   {error, zone_not_found} |
                   {error, not_authoritative}.

Find a zone for a given qname.

find_zone(Qname, Authorities)

-spec find_zone(dns:dname(), {error, any()} | {ok, dns:rr()} | [dns:rr()] | dns:rr()) ->
                   #zone{name :: dns:dname(),
                         version :: binary(),
                         authority :: [dns:rr()],
                         record_count :: non_neg_integer(),
                         records :: [dns:rr()] | trimmed,
                         records_by_name :: #{binary() => [dns:rr()]} | trimmed,
                         records_by_type :: term(),
                         keysets :: [erldns:keyset()]} |
                   {error, zone_not_found} |
                   {error, not_authoritative}.

Find a zone for a given qname.

get_authority(Message)

-spec get_authority(dns:message() | dns:dname()) ->
                       {error, no_question} | {error, authority_not_found} | {ok, dns:authority()}.

Find the SOA record for the given DNS question.

get_delegations(Name)

-spec get_delegations(dns:dname()) -> [dns:rr()] | [].

Get the list of NS and glue records for the given name. This function will always return a list, even if it is empty.

get_records_by_name(Name)

-spec get_records_by_name(dns:dname()) -> [dns:rr()].

Return the record set for the given dname.

get_records_by_name_and_type(Name, Type)

-spec get_records_by_name_and_type(dns:dname(), dns:type()) -> [dns:rr()].

Get all records for the given type and given name.

get_rrset_sync_counter(ZoneName, RRFqdn, Type)

-spec get_rrset_sync_counter(dns:dname(), dns:dname(), dns:type()) -> integer().

Return current sync counter

get_zone(Name)

-spec get_zone(dns:dname()) ->
                  {ok,
                   #zone{name :: dns:dname(),
                         version :: binary(),
                         authority :: [dns:rr()],
                         record_count :: non_neg_integer(),
                         records :: [dns:rr()] | trimmed,
                         records_by_name :: #{binary() => [dns:rr()]} | trimmed,
                         records_by_type :: term(),
                         keysets :: [erldns:keyset()]}} |
                  {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_zone_records(Name)

-spec get_zone_records(dns:dname()) -> [dns:rr()].

Get all records for the given zone.

get_zone_with_records(Name)

This function is deprecated. Use erldns_zone_cache:get_zone/1 to get the zone meta data and erldns_zone_cache:get_zone_records/1 to get the records for the zone..
-spec get_zone_with_records(dns:dname()) ->
                               {ok,
                                #zone{name :: dns:dname(),
                                      version :: binary(),
                                      authority :: [dns:rr()],
                                      record_count :: non_neg_integer(),
                                      records :: [dns:rr()] | trimmed,
                                      records_by_name :: #{binary() => [dns:rr()]} | trimmed,
                                      records_by_type :: term(),
                                      keysets :: [erldns:keyset()]}} |
                               {error, zone_not_found}.

Get a zone for the specific name, including the records for the zone.

handle_call(Message, From, State)

handle_cast(Message, State)

handle_info(Message, State)

in_zone(Name)

-spec in_zone(binary()) -> boolean().

Check if the name is in a zone.

init(_)

-spec init([]) -> {ok, #state{parsers :: term(), tref :: term()}}.

Initialize the zone cache.

put_zone(_)

-spec put_zone({Name, Sha, Records, Keys} | {Name, Sha, Records}) -> ok | {error, Reason :: term()}
                  when
                      Name :: binary(),
                      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.

put_zone(Name, Zone)

-spec put_zone(dns:name(), erldns:zone()) -> ok | {error, Reason :: term()}.

Put a zone into the cache and wait for a response.

put_zone_rrset(_, RRFqdn, Type, Counter)

-spec put_zone_rrset({dns:dname(), binary(), [dns:rr()]} | {dns:dname(), binary(), [dns:rr()], [any()]},
                     dns:dname(),
                     dns:type(),
                     integer()) ->
                        ok | {error, Reason :: term()}.

Put zone RRSet

record_name_in_zone(ZoneName, Name)

-spec record_name_in_zone(binary(), dns:dname()) -> boolean().

Check if the record name is in the zone. Will also return true if a wildcard is present at the node.

start_link()

-spec start_link() -> any().

Start the zone cache process.

terminate(Reason, State)

update_zone_records_and_digest(ZoneName, RecordsCount, Digest)

-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.

zone_names_and_versions()

-spec zone_names_and_versions() -> [{dns:dname(), binary()}].

Return a list of tuples with each tuple as a name and the version SHA for the zone.