return true;
}
-void checkRRSet(const vector<DNSResourceRecord>& oldrrs, vector<DNSResourceRecord>& allrrs, const ZoneName& zone, bool allowUnderscores, vector<pair<DNSResourceRecord, string>>& errors)
+void checkRRSet(const vector<DNSResourceRecord>& oldrrs, vector<DNSResourceRecord>& allrrs, const ZoneName& zone, RRSetFlags flags, vector<pair<DNSResourceRecord, string>>& errors)
{
// QTypes that MUST NOT have multiple records of the same type in a given RRset.
static const std::set<uint16_t> onlyOneEntryTypes = {QType::CNAME, QType::DNAME, QType::SOA};
}
// Check if the DNSNames that should be hostnames, are hostnames
+ bool allowUnderscores = (flags & RRSET_ALLOW_UNDERSCORES) != 0;
try {
checkHostnameCorrectness(rec, allowUnderscores);
}
// whitespace or a leading dot forbidden.
bool validateViewName(std::string_view name, std::string& error);
+enum RRSetFlags : unsigned int
+{
+ RRSET_ALLOW_UNDERSCORES = 1 << 0, // Allow underscore in names
+};
+
// Returns the list of errors found for new records which violate RRset
// constraints.
// NOTE: sorts records in-place.
// *) no exact duplicates
// *) no duplicates for QTypes that can only be present once per RRset
// *) hostnames are hostnames
-void checkRRSet(const vector<DNSResourceRecord>& oldrrs, vector<DNSResourceRecord>& allrrs, const ZoneName& zone, bool allowUnderscores, vector<pair<DNSResourceRecord, string>>& errors);
+void checkRRSet(const vector<DNSResourceRecord>& oldrrs, vector<DNSResourceRecord>& allrrs, const ZoneName& zone, RRSetFlags flags, vector<pair<DNSResourceRecord, string>>& errors);
} // namespace Check
}
std::vector<std::pair<DNSResourceRecord, string>> errors;
- Check::checkRRSet(oldrrs, newrrs, zone, allowUnderscores, errors);
+ Check::RRSetFlags flags{0};
+ if (allowUnderscores) {
+ flags = Check::RRSET_ALLOW_UNDERSCORES;
+ }
+ Check::checkRRSet(oldrrs, newrrs, zone, flags, errors);
oldrrs.clear(); // no longer needed
if (!errors.empty()) {
for (const auto& error : errors) {
{
std::vector<std::pair<DNSResourceRecord, string>> errors;
- Check::checkRRSet({}, records, zone, allowUnderscores, errors);
+ Check::RRSetFlags flags{0};
+ if (allowUnderscores) {
+ flags = Check::RRSET_ALLOW_UNDERSCORES;
+ }
+ Check::checkRRSet({}, records, zone, flags, errors);
if (errors.empty()) {
return true;
}