return NS record for localhost.loki to squash errors in host lookups

pull/1173/head
Jeff Becker 4 years ago committed by Jason Rhinelander
parent 6715b86d51
commit 51516f751b

@ -193,6 +193,31 @@ namespace llarp
}
}
void
Message::AddNSReply(std::string name, RR_TTL_t ttl)
{
if(not questions.empty())
{
hdr_fields = reply_flags(hdr_fields);
const auto& question = questions[0];
answers.emplace_back();
auto& rec = answers.back();
rec.rr_name = question.qname;
rec.rr_type = qTypeNS;
rec.rr_class = qClassIN;
rec.ttl = ttl;
std::array< byte_t, 512 > tmp = {{0}};
llarp_buffer_t buf(tmp);
if(EncodeName(&buf, name))
{
buf.sz = buf.cur - buf.base;
rec.rData.resize(buf.sz);
memcpy(rec.rData.data(), buf.base, buf.sz);
}
}
}
void
Message::AddCNAMEReply(std::string name, RR_TTL_t ttl)
{

@ -69,6 +69,9 @@ namespace llarp
void
AddAReply(std::string name, RR_TTL_t ttl = 1);
void
AddNSReply(std::string name, RR_TTL_t ttl = 1);
bool
Encode(llarp_buffer_t* buf) const override;

@ -513,7 +513,8 @@ namespace llarp
const bool isV4 = msg.questions[0].qtype == dns::qTypeA;
llarp::service::Address addr;
if(isV6 && !SupportsV6())
{ // empty reply but not a NXDOMAIN so that client can retry IPv4
{ // empty reply but not a NXDOMAIN so that client can retry IPv4
msg.AddNSReply("localhost.loki.");
}
// on MacOS this is a typeA query
else if(is_random_snode(msg))

Loading…
Cancel
Save