mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-11-15 12:13:24 +00:00
Merge pull request #271 from neuroscr/master
fix random.snode on MacOS and .snode not found
This commit is contained in:
commit
da556b4f6e
@ -199,6 +199,7 @@ namespace llarp
|
|||||||
TunEndpoint::HandleHookedDNSMessage(
|
TunEndpoint::HandleHookedDNSMessage(
|
||||||
dns::Message &&msg, std::function< void(dns::Message) > reply)
|
dns::Message &&msg, std::function< void(dns::Message) > reply)
|
||||||
{
|
{
|
||||||
|
//llarp::LogInfo("Tun.HandleHookedDNSMessage ", msg.questions[0].qname);
|
||||||
if(msg.questions.size() != 1)
|
if(msg.questions.size() != 1)
|
||||||
{
|
{
|
||||||
llarp::LogWarn("bad number of dns questions: ", msg.questions.size());
|
llarp::LogWarn("bad number of dns questions: ", msg.questions.size());
|
||||||
@ -247,8 +248,17 @@ namespace llarp
|
|||||||
else if(msg.questions[0].qtype == dns::qTypeA)
|
else if(msg.questions[0].qtype == dns::qTypeA)
|
||||||
{
|
{
|
||||||
llarp::service::Address addr;
|
llarp::service::Address addr;
|
||||||
// forward dns
|
// on MacOS this is a typeA query
|
||||||
if(msg.questions[0].qname == "localhost.loki"
|
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
|
||||||
|
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;
|
||||||
@ -287,9 +297,16 @@ namespace llarp
|
|||||||
// TODO: add hook to EnsurePathToSNode
|
// TODO: add hook to EnsurePathToSNode
|
||||||
EnsurePathToSNode(addr.as_array());
|
EnsurePathToSNode(addr.as_array());
|
||||||
huint32_t ip = ObtainIPForAddr(addr, true);
|
huint32_t ip = ObtainIPForAddr(addr, true);
|
||||||
msg.AddINReply(ip);
|
if (ip.h)
|
||||||
|
msg.AddINReply(ip);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
llarp::LogWarn("no ip found for ", addr);
|
||||||
|
msg.AddNXReply();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
// forward dns
|
||||||
msg.AddNXReply();
|
msg.AddNXReply();
|
||||||
|
|
||||||
reply(msg);
|
reply(msg);
|
||||||
|
Loading…
Reference in New Issue
Block a user