Struct trust_dns::authority::Authority [] [src]

pub struct Authority {
    // some fields omitted
}

Authority is the storage method for all resource records

Methods

impl Authority

Authority is responsible for storing the resource records for a particular zone.

Authorities default to DNSClass IN. The ZoneType specifies if this should be treated as the start of authority for the zone, is a slave, or a cached zone.

fn new(origin: Name, records: BTreeMap<RrKey, RRSet>, zone_type: ZoneType, allow_update: bool) -> Authority

Creates a new Authority.

Arguments

  • origin - The zone Name being created, this should match that of the RecordType::SOA record.
  • records - The HashMap of the initial set of records in the zone.
  • zone_type - The type of zone, i.e. is this authoritative?
  • allow_update - If true, then this zone accepts dynamic updates.

Return value

The new Authority.

fn add_secure_key(&mut self, signer: Signer)

fn get_origin(&self) -> &Name

fn get_zone_type(&self) -> ZoneType

fn get_soa(&self) -> Option<&Record>

Returns the SOA of the authority.

Note This will only return the SOA, if this is fullfilling a request, a standard lookup should be used, see get_soa_secure(), which will optionally return RRSIGs.

fn get_soa_secure(&self, is_secure: bool) -> Vec<&Record>

Returns the SOA record

fn get_minimum_ttl(&self) -> u32

fn get_ns(&self, is_secure: bool) -> Vec<&Record>

fn upsert(&mut self, record: Record, serial: u32) -> bool

Inserts or updates a Record depending on it's existence in the authority.

Guarantees that SOA, CNAME only has one record, will implicitly update if they already exist.

Arguments

  • record - The Record to be inserted or updated.
  • serial - Current serial number to be recorded against updates.

Return value

Ok() on success or Err() with the ResponseCode associated with the error.

fn update(&mut self, update: &Message) -> UpdateResult<bool>

Takes the UpdateMessage, extracts the Records, and applies the changes to the record set.

RFC 2136, DNS Update, April 1997


3.4 - Process Update Section

  Next, the Update Section is processed as follows.

3.4.2 - Update

  The Update Section is parsed into RRs and these RRs are processed in
  order.

3.4.2.1. If any system failure (such as an out of memory condition,
  or a hardware error in persistent storage) occurs during the
  processing of this section, signal SERVFAIL to the requestor and undo
  all updates applied to the zone during this transaction.

3.4.2.2. Any Update RR whose CLASS is the same as ZCLASS is added to
  the zone.  In case of duplicate RDATAs (which for SOA RRs is always
  the case, and for WKS RRs is the case if the ADDRESS and PROTOCOL
  fields both match), the Zone RR is replaced by Update RR.  If the
  TYPE is SOA and there is no Zone SOA RR, or the new SOA.SERIAL is
  lower (according to [RFC1982]) than or equal to the current Zone SOA
  RR's SOA.SERIAL, the Update RR is ignored.  In the case of a CNAME
  Update RR and a non-CNAME Zone RRset or vice versa, ignore the CNAME
  Update RR, otherwise replace the CNAME Zone RR with the CNAME Update
  RR.

3.4.2.3. For any Update RR whose CLASS is ANY and whose TYPE is ANY,
  all Zone RRs with the same NAME are deleted, unless the NAME is the
  same as ZNAME in which case only those RRs whose TYPE is other than
  SOA or NS are deleted.  For any Update RR whose CLASS is ANY and
  whose TYPE is not ANY all Zone RRs with the same NAME and TYPE are
  deleted, unless the NAME is the same as ZNAME in which case neither
  SOA or NS RRs will be deleted.

3.4.2.4. For any Update RR whose class is NONE, any Zone RR whose
  NAME, TYPE, RDATA and RDLENGTH are equal to the Update RR is deleted,
  unless the NAME is the same as ZNAME and either the TYPE is SOA or
  the TYPE is NS and the matching Zone RR is the only NS remaining in
  the RRset, in which case this Update RR is ignored.

3.4.2.5. Signal NOERROR to the requestor.

Arguments

  • update - The UpdateMessage records will be extracted and used to perform the update actions as specified in the above RFC.

Return value

true if any of additions, updates or deletes were made to the zone, false otherwise. Err is returned in the case of bad data, etc.

fn search(&self, query: &Query, is_secure: bool) -> Vec<&Record>

Using the specified query, perform a lookup against this zone.

Arguments

  • query - the query to perform the lookup with.
  • is_secure - if true, then RRSIG records (if this is a secure zone) will be returned.

Return value

Returns a vectory containing the results of the query, it will be empty if not found. If is_secure is true, in the case of no records found then NSEC records will be returned.

fn lookup(&self, name: &Name, rtype: RecordType, is_secure: bool) -> Vec<&Record>

Looks up all Resource Records matching the giving Name and RecordType.

Arguments

  • name - The Name, label, to lookup.
  • rtype - The RecordType, to lookup. RecordType::ANY will return all records matching name. RecordType::AXFR will return all record types except RecordType::SOA due to the requirements that on zone transfers the RecordType::SOA must both preceed and follow all other records.
  • is_secure - If the DO bit is set on the EDNS OPT record, then return RRSIGs as well.

Return value

None if there are no matching records, otherwise a Vec containing the found records.

fn get_nsec_records(&self, name: &Name, is_secure: bool) -> Vec<&Record>

Return the NSEC records based on the given name

Arguments

  • name - given this name (i.e. the lookup name), return the NSEC record that is less than this
  • is_secure - if true then it will return RRSIG records as well

fn secure_zone(&mut self)

(Re)generates the nsec records, increments the serial number nad signs the zone