try fixing AAAA record handling, return NOERROR with no records.

pull/250/head
Jeff Becker 5 years ago
parent 7489ab1380
commit 9e50e2d34a
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -7,6 +7,7 @@ namespace llarp
{ {
namespace dns namespace dns
{ {
constexpr uint16_t qTypeAAAA = 28;
constexpr uint16_t qTypeTXT = 16; constexpr uint16_t qTypeTXT = 16;
constexpr uint16_t qTypeMX = 15; constexpr uint16_t qTypeMX = 15;
constexpr uint16_t qTypePTR = 12; constexpr uint16_t qTypePTR = 12;

@ -247,14 +247,17 @@ namespace llarp
{ {
hdr_fields |= (1 << 15) | (1 << 3); hdr_fields |= (1 << 15) | (1 << 3);
const auto& question = questions[0]; const auto& question = questions[0];
answers.emplace_back(); if(question.qtype != qTypeAAAA)
auto& nx = answers.back(); {
nx.rr_name = question.qname; answers.emplace_back();
nx.rr_type = question.qtype; auto& nx = answers.back();
nx.rr_class = question.qclass; nx.rr_name = question.qname;
nx.ttl = ttl; nx.rr_type = question.qtype;
nx.rData.resize(1); nx.rr_class = question.qclass;
nx.rData.data()[0] = 0; nx.ttl = ttl;
nx.rData.resize(1);
nx.rData.data()[0] = 0;
}
} }
} }

@ -246,17 +246,9 @@ namespace llarp
} }
else if(msg.questions[0].qtype == dns::qTypeA) else if(msg.questions[0].qtype == dns::qTypeA)
{ {
// forward dns
llarp::service::Address addr; llarp::service::Address addr;
if(qname == "random.snode" || qname == "random.snode.") // forward dns
{ if(msg.questions[0].qname == "localhost.loki"
RouterID random;
if(Router()->GetRandomGoodRouter(random))
msg.AddCNAMEReply(random.ToString(), 1);
else
msg.AddNXReply();
}
else if(msg.questions[0].qname == "localhost.loki"
|| msg.questions[0].qname == "localhost.loki.") || msg.questions[0].qname == "localhost.loki.")
{ {
size_t counter = 0; size_t counter = 0;
@ -351,18 +343,17 @@ namespace llarp
// hook random.snode for CNAME // hook random.snode for CNAME
if(msg.questions[0].qname == "random.snode" if(msg.questions[0].qname == "random.snode"
|| msg.questions[0].qname == "random.snode.") || msg.questions[0].qname == "random.snode.")
return msg.questions[0].qtype == llarp::dns::qTypeCNAME; return true;
// hook localhost.loki for CNAME and A records // hook localhost.loki
if(msg.questions[0].qname == "localhost.loki" if(msg.questions[0].qname == "localhost.loki"
|| msg.questions[0].qname == "localhost.loki.") || msg.questions[0].qname == "localhost.loki.")
return msg.questions[0].qtype == llarp::dns::qTypeCNAME return true;
|| msg.questions[0].qtype == llarp::dns::qTypeA;
// hook .loki A records // hook .loki A records
if(addr.FromString(msg.questions[0].qname, ".loki")) if(addr.FromString(msg.questions[0].qname, ".loki"))
return msg.questions[0].qtype == llarp::dns::qTypeA; return true;
// hook .snode A records // hook .snode A records
if(addr.FromString(msg.questions[0].qname, ".snode")) if(addr.FromString(msg.questions[0].qname, ".snode"))
return msg.questions[0].qtype == llarp::dns::qTypeA; return true;
// hook any ranges we own // hook any ranges we own
if(msg.questions[0].qtype == llarp::dns::qTypePTR) if(msg.questions[0].qtype == llarp::dns::qTypePTR)
{ {

Loading…
Cancel
Save