wire up lns gotnamemessage handler to kitchen sink

pull/1351/head
Jeff 4 years ago
parent 5d43a804d1
commit 78b40d6725

@ -231,7 +231,7 @@ namespace llarp
{
if (multiValued)
{
for (const auto& value : parsedValues)
for (auto value : parsedValues)
{
acceptor(value);
}

@ -1,5 +1,8 @@
#include <dht/messages/gotname.hpp>
#include <lokimq/bt_serialize.h>
#include <dht/context.hpp>
#include <router/abstractrouter.hpp>
#include <path/path_context.hpp>
namespace llarp::dht
{
@ -47,9 +50,13 @@ namespace llarp::dht
}
bool
GotNameMessage::HandleMessage(struct llarp_dht_context*, std::vector<Ptr_t>&) const
GotNameMessage::HandleMessage(struct llarp_dht_context* ctx, std::vector<Ptr_t>&) const
{
return false;
auto pathset = ctx->impl->GetRouter()->pathContext().GetLocalPathSet(pathID);
if (pathset == nullptr)
return false;
auto copy = std::make_shared<const GotNameMessage>(*this);
return pathset->HandleGotNameMessage(copy);
}
} // namespace llarp::dht

@ -474,14 +474,21 @@ namespace llarp
{
return LookupNameAsync(
qname,
[msg = std::make_shared<dns::Message>(msg), isV6, reply, ReplyToLokiDNSWhenReady](
auto maybe) {
[msg = std::make_shared<dns::Message>(msg),
name = Name(),
qname,
isV6,
reply,
ReplyToLokiDNSWhenReady](auto maybe) {
if (not maybe.has_value())
{
LogWarn(name, " lns name ", qname, " not resolved");
msg->AddNXReply();
reply(*msg);
return;
}
LogInfo(name, " ", qname, " resolved to ", maybe->ToString());
msg->AddCNAMEReply(maybe->ToString());
ReplyToLokiDNSWhenReady(*maybe, msg, isV6);
});
}

@ -778,6 +778,7 @@ namespace llarp
handler(maybe);
return true;
}
LogInfo(Name(), " looking up LNS name: ", name);
auto path = PickRandomEstablishedPath();
auto job = new LookupNameJob(this, GenTXID(), name, handler);
return job->SendRequestViaPath(path, m_router);

Loading…
Cancel
Save