/* APL end */
+/* SVCB start */
+bool SVCBBaseRecordContent::autoHint(const SvcParam::SvcParamKey &key) const {
+ 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 false;
+ }
+ return p->getAutoHint();
+}
+
+void SVCBBaseRecordContent::setHints(const SvcParam::SvcParamKey &key, const std::vector<ComboAddress> &addresses) {
+ 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;
+ }
+ std::vector<ComboAddress> h;
+ h.reserve(h.size() + addresses.size());
+ h.insert(h.end(), addresses.begin(), addresses.end());
+ try {
+ auto newParam = SvcParam(key, std::move(h));
+ d_params.erase(p);
+ d_params.insert(newParam);
+ } catch(...) {
+ // XXX maybe we should SERVFAIL instead?
+ return;
+ }
+}
+
+/* SVCB end */
+
boilerplate_conv(TKEY,
conv.xfrName(d_algo);
conv.xfr32BitInt(d_inception);
public:
const DNSName& getTarget() const {return d_target;}
uint16_t getPriority() const {return d_priority;}
+ // Returns true if a value for |key| was set to 'auto'
+ 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);
protected:
uint16_t d_priority;
while (B.get(rr)) {
rr.dr.d_place = DNSResourceRecord::ADDITIONAL;
switch (qtype) {
- case QType::SVCB: {
- auto rrc = getRR<SVCBRecordContent>(rr.dr);
- r->addRecord(std::move(rr));
- ret = rrc->getTarget().isRoot() ? ret : rrc->getTarget();
- if (rrc->getPriority() == 0) {
- done = false;
- }
- break;
- }
+ case QType::SVCB: /* fall-through */
case QType::HTTPS: {
- auto rrc = getRR<HTTPSRecordContent>(rr.dr);
+ auto rrc = getRR<SVCBBaseRecordContent>(rr.dr);
r->addRecord(std::move(rr));
ret = rrc->getTarget().isRoot() ? ret : rrc->getTarget();
if (rrc->getPriority() == 0) {
case QType::SRV:
content=getRR<SRVRecordContent>(rr.dr)->d_target;
break;
- case QType::SVCB: {
- auto rrc = getRR<SVCBRecordContent>(rr.dr);
- content = rrc->getTarget();
- if (content.isRoot()) {
- content = rr.dr.d_name;
- }
- content = doAdditionalServiceProcessing(content, rr.dr.d_type, r);
- break;
- }
+ case QType::SVCB: /* fall-through */
case QType::HTTPS: {
- auto rrc = getRR<HTTPSRecordContent>(rr.dr);
+ auto rrc = getRR<SVCBBaseRecordContent>(rr.dr);
content = rrc->getTarget();
if (content.isRoot()) {
content = rr.dr.d_name;
const std::string& getEchConfig() const;
const std::string& getValue() const;
+ bool getAutoHint() const { return d_autohint; };
+ void setAutoHint(const bool value) { d_autohint = value; };
+
private:
SvcParamKey d_key;
std::string d_value; // For keyNNNNN vals
std::string d_echconfig; // For echconfig
uint16_t d_port{0}; // For port
+ // Set to true if we encountered an "auto" field in hints
+ // Can only be true when we read SVCParams from text
+ bool d_autohint{false};
+
static const std::map<std::string, SvcParamKey> SvcParams;
};