Merge pull request #275 from majestrate/staging

disable CNAME RR for random.snode A record lookups
This commit is contained in:
Jeff 2019-02-05 09:10:19 -05:00 committed by GitHub
commit 44d84f0da7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 17 deletions

View File

@ -256,6 +256,8 @@ namespace llarp
if(question.qtype != qTypeAAAA)
{
hdr_fields |= flags_RCODENameError;
if(question.qtype == qTypeA)
{
answers.emplace_back();
auto& nx = answers.back();
nx.rr_name = question.qname;
@ -267,6 +269,7 @@ namespace llarp
}
}
}
}
} // namespace dns
} // namespace llarp

View File

@ -199,7 +199,7 @@ namespace llarp
TunEndpoint::HandleHookedDNSMessage(
dns::Message &&msg, std::function< void(dns::Message) > reply)
{
//llarp::LogInfo("Tun.HandleHookedDNSMessage ", msg.questions[0].qname);
// llarp::LogInfo("Tun.HandleHookedDNSMessage ", msg.questions[0].qname);
if(msg.questions.size() != 1)
{
llarp::LogWarn("bad number of dns questions: ", msg.questions.size());
@ -244,6 +244,7 @@ namespace llarp
}
else
msg.AddNXReply();
reply(msg);
}
else if(msg.questions[0].qtype == dns::qTypeA)
{
@ -252,10 +253,7 @@ namespace llarp
if(msg.questions[0].qname == "random.snode"
|| msg.questions[0].qname == "random.snode.")
{
RouterID random;
if(Router()->GetRandomGoodRouter(random))
msg.AddCNAMEReply(random.ToString(), 1);
else
// don't reply to A queries, applications MUST use CNAME queries
msg.AddNXReply();
}
else if(msg.questions[0].qname == "localhost.loki"
@ -297,7 +295,7 @@ namespace llarp
// TODO: add hook to EnsurePathToSNode
EnsurePathToSNode(addr.as_array());
huint32_t ip = ObtainIPForAddr(addr, true);
if (ip.h)
if(ip.h)
msg.AddINReply(ip);
else
{
@ -357,7 +355,7 @@ namespace llarp
// always hook mx records
if(msg.questions[0].qtype == llarp::dns::qTypeMX)
return true;
// hook random.snode for CNAME
// hook random.snode
if(msg.questions[0].qname == "random.snode"
|| msg.questions[0].qname == "random.snode.")
return true;