fn scan_node<'a>(
    zone: &'a Zone,
    node: &'a Node,
    at_apex: bool,
    in_authoritative: bool,
    issues: &mut Vec<ValidationIssue<'a>>,
) -> Result<(), Error> {
    // Perform CNAME checks (6 and 7).
    if let Some(cname_rrset) = node.rrsets.lookup(Type::CNAME) {
        if node.rrsets.len() != 1 {
            issues.push(ValidationIssue::OtherRecordsAtCname(&node.name));
        }
        if cname_rrset.rdatas().count() != 1 {
            issues.push(ValidationIssue::DuplicateCname(&node.name));
        }
    }

    // Perform the MX address check (9).
    if let Some(mx_rrset) = node.rrsets.lookup(Type::MX) {
        for rdata in mx_rrset.rdatas() {
            let name = rdata
                .get(2..)
                .map(Name::try_from_uncompressed_all)
                .and_then(Result::ok)
                .ok_or(Error::InvalidRdata)?;
            check_mx_address(zone, name, issues);
        }
    }

    // Perform glue (3) and in-zone NS address (8) checks.
    // TODO: should we also check occluded NS records, or just NS
    //       records currently in authoritative data as we do now?
    let at_delegation_point;
    if !at_apex && in_authoritative {
        if let Some(ns_rrset) = node.rrsets.lookup(Type::NS) {
            at_delegation_point = false;
            for rdata in ns_rrset.rdatas() {
                let nsdname =
                    Name::try_from_uncompressed_all(rdata).or(Err(Error::InvalidRdata))?;
                check_delegation_ns_address(zone, nsdname, &node.name, issues);
            }
        } else {
            at_delegation_point = true;
        }
    } else {
        at_delegation_point = true;
    }

    for child in node.children.values() {
        scan_node(zone, child, false, at_delegation_point, issues)?;
    }
    Ok(())
}
/// Scans a node, checking for semantic errors and warnings. After
/// checking the current node, all of its children are scanned. This
/// implements checks 3, 6, 7, and 8.
Scans a node, checking for semantic errors and warnings. After
checking the current node, all of its children are scanned. This
implements checks 3, 6, 7, and 8.
Scans a node checking for semantic errors and warnings . After checking the current node all of its children are scanned . This implements checks 3 6 7 and 8 .
fn scan_node<'a>(
    zone: &'a Zone,
    node: &'a Node,
    at_apex: bool,
    in_authoritative: bool,
    issues: &mut Vec<ValidationIssue<'a>>,
) -> Result<(), Error> {
    // Perform CNAME checks (6 and 7).
    if let Some(cname_rrset) = node.rrsets.lookup(Type::CNAME) {
        if node.rrsets.len() != 1 {
            issues.push(ValidationIssue::OtherRecordsAtCname(&node.name));
        }
        if cname_rrset.rdatas().count() != 1 {
            issues.push(ValidationIssue::DuplicateCname(&node.name));
        }
    }
    // Perform the MX address check (9).
    if let Some(mx_rrset) = node.rrsets.lookup(Type::MX) {
        for rdata in mx_rrset.rdatas() {
            let name = rdata
                .get(2..)
                .map(Name::try_from_uncompressed_all)
                .and_then(Result::ok)
                .ok_or(Error::InvalidRdata)?;
            check_mx_address(zone, name, issues);
        }
    }
    // Perform glue (3) and in-zone NS address (8) checks.
    // TODO: should we also check occluded NS records, or just NS
    //       records currently in authoritative data as we do now?
    let at_delegation_point;
    if !at_apex && in_authoritative {
        if let Some(ns_rrset) = node.rrsets.lookup(Type::NS) {
            at_delegation_point = false;
            for rdata in ns_rrset.rdatas() {
                let nsdname =
                    Name::try_from_uncompressed_all(rdata).or(Err(Error::InvalidRdata))?;
                check_delegation_ns_address(zone, nsdname, &node.name, issues);
            }
        } else {
            at_delegation_point = true;
        }
    } else {
        at_delegation_point = true;
    }
    for child in node.children.values() {
        scan_node(zone, child, false, at_delegation_point, issues)?;
    }
    Ok(())
}
fn scan_node < ' a > ( zone : & ' a Zone , node : & ' a Node , at_apex : bool , in_authoritative : bool , issues : & mut Vec < ValidationIssue < ' a > > , ) -> Result < ( ) , Error > { // Perform CNAME checks (6 and 7). if let Some ( cname_rrset ) = node . rrsets . lookup ( Type :: CNAME ) { if node . rrsets . len ( ) != 1 { issues . push ( ValidationIssue :: OtherRecordsAtCname ( & node . name ) ) ; } if cname_rrset . rdatas ( ) . count ( ) != 1 { issues . push ( ValidationIssue :: DuplicateCname ( & node . name ) ) ; } } // Perform the MX address check (9). if let Some ( mx_rrset ) = node . rrsets . lookup ( Type :: MX ) { for rdata in mx_rrset . rdatas ( ) { let name = rdata . get ( 2 .. ) . map ( Name :: try_from_uncompressed_all ) . and_then ( Result :: ok ) . ok_or ( Error :: InvalidRdata ) ? ; check_mx_address ( zone , name , issues ) ; } } // Perform glue (3) and in-zone NS address (8) checks. // TODO: should we also check occluded NS records, or just NS //       records currently in authoritative data as we do now? let at_delegation_point ; if ! at_apex && in_authoritative { if let Some ( ns_rrset ) = node . rrsets . lookup ( Type :: NS ) { at_delegation_point = false ; for rdata in ns_rrset . rdatas ( ) { let nsdname = Name :: try_from_uncompressed_all ( rdata ) . or ( Err ( Error :: InvalidRdata ) ) ? ; check_delegation_ns_address ( zone , nsdname , & node . name , issues ) ; } } else { at_delegation_point = true ; } } else { at_delegation_point = true ; } for child in node . children . values ( ) { scan_node ( zone , child , false , at_delegation_point , issues ) ? ; } Ok ( ( ) ) }
Scans a node, checking for semantic errors and warnings.
Scans a node checking for semantic errors and warnings .
zone
&'a Zone
node
&'a Node
at_apex
bool
in_authoritative
bool
issues
&mut Vec<ValidationIssue<'a>>
zone
&'a Zone
node
&'a Node
at_apex
bool
in_authoritative
bool
issues
&mut Vec<ValidationIssue<'a>>