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
|
2020-04-07 18:38:56 +00:00
|
|
|
TagLookup::Validate(const service::EncryptedIntroSet& introset) const
|
2019-01-22 01:14:02 +00:00
|
|
|
{
|
2020-04-07 18:38:56 +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;
|
|
|
|
}
|
2020-04-07 18:38:56 +00:00
|
|
|
if (not introset.topic.has_value())
|
2020-01-27 21:30:41 +00:00
|
|
|
return false;
|
2020-04-07 18:38:56 +00:00
|
|
|
if (introset.topic.value() != target)
|
2019-01-22 01:14:02 +00:00
|
|
|
{
|
|
|
|
llarp::LogWarn("got introset with missmatched topic in tag lookup");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2020-04-07 18:38:56 +00:00
|
|
|
TagLookup::Start(const TXOwner& peer)
|
2019-01-22 01:14:02 +00:00
|
|
|
{
|
2020-04-07 18:38:56 +00:00
|
|
|
parent->DHTSendTo(peer.node.as_array(), new FindIntroMessage(target, peer.txid));
|
2019-01-22 01:14:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TagLookup::SendReply()
|
|
|
|
{
|
2020-04-07 18:38:56 +00:00
|
|
|
parent->DHTSendTo(whoasked.node.as_array(), new GotIntroMessage({}, whoasked.txid));
|
2019-01-22 01:14:02 +00:00
|
|
|
}
|
|
|
|
} // namespace dht
|
|
|
|
} // namespace llarp
|