return arrs;
}
+vector<DNSZoneRecord*> DNSPacket::getServiceRecords()
+{
+ vector<DNSZoneRecord*> arrs;
+
+ for(auto & i : d_rrs) {
+ if (i.dr.d_type==QType::SVCB ||
+ i.dr.d_type==QType::HTTPS) {
+ arrs.push_back(&i);
+ }
+ }
+ return arrs;
+}
+
vector<DNSZoneRecord*> DNSPacket::getAnswerRecords()
{
vector<DNSZoneRecord*> arrs;
vector<DNSZoneRecord*> getAPRecords(); //!< get a vector with DNSZoneRecords that need additional processing
vector<DNSZoneRecord*> getAnswerRecords(); //!< get a vector with DNSZoneRecords that are answers
+ vector<DNSZoneRecord*> getServiceRecords(); //!< Get a vector with all Service-style (SVCB) records
void setCompress(bool compress);
std::unique_ptr<DNSPacket> replyPacket() const; //!< convenience function that creates a virgin answer packet to this question
}
}
+void SVCBBaseRecordContent::removeParam(const SvcParam::SvcParamKey &key) {
+ auto p = std::find_if(d_params.begin(), d_params.end(),
+ [&key](const SvcParam ¶m) {
+ return param.getKey() == key;
+ });
+ if (p == d_params.end()) {
+ return;
+ }
+ d_params.erase(p);
+}
+
/* SVCB end */
boilerplate_conv(TKEY,
bool autoHint(const SvcParam::SvcParamKey &key) const;
// Sets the |addresses| to the existing hints for |key|
void setHints(const SvcParam::SvcParamKey &key, const std::vector<ComboAddress> &addresses);
+ // Removes the parameter for |key| from d_params
+ void removeParam(const SvcParam::SvcParamKey &key);
protected:
uint16_t d_priority;
}
}
}
+ // TODO should we have a setting to do this?
+ for (auto &rec : r->getServiceRecords()) {
+ // Process auto hints
+ auto rrc = getRR<SVCBBaseRecordContent>(rec->dr);
+ DNSName target = rrc->getTarget().isRoot() ? rec->dr.d_name : rrc->getTarget();
+ if (rrc->autoHint(SvcParam::ipv4hint)) {
+ B.lookup(QType::A, target, d_sd.domain_id);
+ vector<ComboAddress> hints;
+ DNSZoneRecord rr;
+ while (B.get(rr)) {
+ auto arrc = getRR<ARecordContent>(rr.dr);
+ hints.push_back(arrc->getCA());
+ }
+ if (hints.size() == 0) {
+ rrc->removeParam(SvcParam::ipv4hint);
+ } else {
+ rrc->setHints(SvcParam::ipv4hint, hints);
+ }
+ }
+
+ if (rrc->autoHint(SvcParam::ipv6hint)) {
+ B.lookup(QType::AAAA, target, d_sd.domain_id);
+ vector<ComboAddress> hints;
+ DNSZoneRecord rr;
+ while (B.get(rr)) {
+ auto arrc = getRR<AAAARecordContent>(rr.dr);
+ hints.push_back(arrc->getCA());
+ }
+ if (hints.size() == 0) {
+ rrc->removeParam(SvcParam::ipv6hint);
+ } else {
+ rrc->setHints(SvcParam::ipv6hint, hints);
+ }
+ }
+ }
DNSZoneRecord dzr;
for(const auto& name : lookup) {
}
}
+ for (auto loopRR : zrrs) {
+ if ((loopRR.dr.d_type == QType::SVCB || loopRR.dr.d_type == QType::HTTPS)) {
+ // Process auto hints
+ // TODO this is an almost copy of the code in the packethandler
+ auto rrc = getRR<SVCBBaseRecordContent>(loopRR.dr);
+ if (rrc == nullptr) {
+ continue;
+ }
+ DNSName svcTarget = rrc->getTarget().isRoot() ? loopRR.dr.d_name : rrc->getTarget();
+ if (rrc->autoHint(SvcParam::ipv4hint)) {
+ sd.db->lookup(QType::A, svcTarget, sd.domain_id);
+ vector<ComboAddress> hints;
+ DNSZoneRecord rr;
+ while (sd.db->get(rr)) {
+ auto arrc = getRR<ARecordContent>(rr.dr);
+ hints.push_back(arrc->getCA());
+ }
+ if (hints.size() == 0) {
+ rrc->removeParam(SvcParam::ipv4hint);
+ } else {
+ rrc->setHints(SvcParam::ipv4hint, hints);
+ }
+ }
+
+ if (rrc->autoHint(SvcParam::ipv6hint)) {
+ sd.db->lookup(QType::AAAA, svcTarget, sd.domain_id);
+ vector<ComboAddress> hints;
+ DNSZoneRecord rr;
+ while (sd.db->get(rr)) {
+ auto arrc = getRR<AAAARecordContent>(rr.dr);
+ hints.push_back(arrc->getCA());
+ }
+ if (hints.size() == 0) {
+ rrc->removeParam(SvcParam::ipv6hint);
+ } else {
+ rrc->setHints(SvcParam::ipv6hint, hints);
+ }
+ }
+ }
+ }
+
// Group records by name and type, signpipe stumbles over interrupted rrsets
if(securedZone && !presignedZone) {
sort(zrrs.begin(), zrrs.end(), [](const DNSZoneRecord& a, const DNSZoneRecord& b) {