lokinet/llarp/dht/taglookup.cpp

41 lines
929 B
C++
Raw Normal View History

#include "taglookup.hpp"
2019-01-22 01:14:02 +00:00
#include "context.hpp"
#include <llarp/dht/messages/gotintro.hpp>
2019-01-22 01:14:02 +00:00
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