def _axfr_records(self, server, zone): unique = set() records = list() resp = server.dig(zone.name, "AXFR", log_no_sep=True) for msg in resp.resp: for rrset in msg.answer: rrs = rrset.to_text(origin=dns.name.from_text(zone.name), relativize=False).split("\n") for rr in rrs: # Owner to lower-case :-( item = rr.strip().split(" ", 1) item_lower = item[0].lower() + " " + item[1] if item_lower in unique and rrset.rdtype != dns.rdatatype.SOA: detail_log("!Duplicate record server='%s':" % server.name) detail_log(" %s" % item_lower) continue unique.add(item_lower) records.append(item_lower) return unique, records
def check_axfr_style_ixfr(self, server, zone_name, serial): resp_ixfr = server.dig(zone_name, "IXFR", serial=serial) resp_axfr = server.dig(zone_name, "AXFR") resp_ixfr.check_axfr_style_ixfr(resp_axfr)
def _ixfr_changes(self, server, zone, serial, udp): soa = None changes = list() resp = server.dig(zone.name, "IXFR", log_no_sep=True, serial=serial, udp=udp) change = Test.IxfrChange() for msg in resp.resp: for rrset in msg.answer: records = rrset.to_text(origin=dns.name.from_text(zone.name), relativize=False).split("\n") for record in records: item_lower = self._canonize_record(rrset.rdtype, record.strip()) if rrset.rdtype == dns.rdatatype.SOA: if not soa: # IXFR leading SOA. soa = item_lower continue if not change.soa_old: # Remove change section. change.soa_old = item_lower continue if not change.soa_new: # Add change section. change.soa_new = item_lower continue # Next change -> store the actual one. change.sort() changes.append(change) change = Test.IxfrChange() change.soa_old = item_lower else: if not soa: set_err("IXFR FORMAT") detail_log("!Missing leading SOA zone='%s', " \ "server='%s' before:" % (zone.name, server.name)) detail_log(" %s" % item_lower) if not change.soa_old: set_err("IXFR FORMAT") detail_log("!Expected SOA zone='%s', server='%s' " \ "before:" % (zone.name, server.name)) detail_log(" %s" % item_lower) if not change.soa_new: change.rem(item_lower) else: change.add(item_lower) if not soa: set_err("IXFR FORMAT") detail_log("!Missing leading SOA zone='%s', server='%s'" % (zone.name, server.name)) elif change.removed or change.added: set_err("IXFR FORMAT") detail_log("!Missing trailing SOA zone='%s', server='%s'" % (zone.name, server.name)) elif change.soa_old and change.soa_old != soa: set_err("IXFR FORMAT") detail_log("!Trailing SOA differs from the leading one " \ "zone='%s', server='%s'" % (zone.name, server.name)) return soa, changes