add exit.localhost.loki cname record (#1440)

* add exit.localhost.loki cname record

* return cname in localhost.loki A/AAAA lookup reply

* correctly handle case where we have no exit

* typofix

* simplify logic
pull/1441/head
Jeff 4 years ago committed by GitHub
parent eea0929077
commit 87c76a6769
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -461,6 +461,19 @@ namespace llarp
else
msg.AddNXReply();
}
else if (msg.questions[0].IsLocalhost() and msg.questions[0].HasSubdomains())
{
const auto subdomain = msg.questions[0].Subdomains();
if (subdomain == "exit" and HasExit())
{
m_ExitMap.ForEachEntry(
[&msg](const auto&, const auto& exit) { msg.AddCNAMEReply(exit.ToString(), 1); });
}
else
{
msg.AddNXReply();
}
}
else if (is_localhost_loki(msg))
{
size_t counter = 0;
@ -501,21 +514,33 @@ namespace llarp
}
else if (is_localhost_loki(msg))
{
size_t counter = 0;
context->ForEachService(
[&](const std::string&, const std::shared_ptr<service::Endpoint>& service) -> bool {
if (!service->HasIfAddr())
return true;
huint128_t ip = service->GetIfAddr();
if (ip.h)
{
msg.AddINReply(ip, isV6);
++counter;
}
return true;
});
if (counter == 0)
const bool lookingForExit = msg.questions[0].Subdomains() == "exit";
huint128_t ip = GetIfAddr();
if (ip.h)
{
if (lookingForExit)
{
if (HasExit())
{
m_ExitMap.ForEachEntry(
[&msg](const auto&, const auto& exit) { msg.AddCNAMEReply(exit.ToString()); });
msg.AddINReply(ip, isV6);
}
else
{
msg.AddNXReply();
}
}
else
{
msg.AddCNAMEReply(m_Identity.pub.Name(), 1);
msg.AddINReply(ip, isV6);
}
}
else
{
msg.AddNXReply();
}
}
else if (addr.FromString(qname, ".loki"))
{

Loading…
Cancel
Save