lokinet/llarp/dht/taglookup.cpp

41 lines
931 B
C++
Raw Normal View History

2019-01-22 01:14:02 +00:00
#include <dht/taglookup.hpp>
#include <dht/context.hpp>
#include <dht/messages/gotintro.hpp>
namespace llarp
{
namespace dht
{
bool
TagLookup::Validate(const service::EncryptedIntroSet& introset) const
2019-01-22 01:14:02 +00:00
{
if (!introset.Verify(parent->Now()))
2019-01-22 01:14:02 +00:00
{
llarp::LogWarn("got invalid introset from tag lookup");
return false;
}
if (not introset.topic)
2020-01-27 21:30:41 +00:00
return false;
if (*introset.topic != target)
2019-01-22 01:14:02 +00:00
{
llarp::LogWarn("got introset with mismatched topic in tag lookup");
2019-01-22 01:14:02 +00:00
return false;
}
return true;
}
void
TagLookup::Start(const TXOwner& peer)
2019-01-22 01:14:02 +00:00
{
parent->DHTSendTo(peer.node.as_array(), new FindIntroMessage(target, peer.txid));
2019-01-22 01:14:02 +00:00
}
void
TagLookup::SendReply()
{
parent->DHTSendTo(whoasked.node.as_array(), new GotIntroMessage({}, whoasked.txid));
2019-01-22 01:14:02 +00:00
}
} // namespace dht
} // namespace llarp