2018-07-11 13:20:14 +00:00
|
|
|
#ifndef LLARP_DHT_MESSAGES_GOT_INTRO_HPP
|
|
|
|
#define LLARP_DHT_MESSAGES_GOT_INTRO_HPP
|
2018-12-12 02:15:08 +00:00
|
|
|
|
2018-12-12 00:48:54 +00:00
|
|
|
#include <dht/message.hpp>
|
2019-04-22 18:35:19 +00:00
|
|
|
#include <service/intro_set.hpp>
|
2019-05-03 13:15:03 +00:00
|
|
|
#include <util/copy_or_nullptr.hpp>
|
2018-12-12 02:15:08 +00:00
|
|
|
|
2018-07-20 04:50:28 +00:00
|
|
|
#include <vector>
|
2020-01-23 12:11:11 +00:00
|
|
|
#include <absl/types/optional.h>
|
2018-07-11 13:20:14 +00:00
|
|
|
|
|
|
|
namespace llarp
|
|
|
|
{
|
|
|
|
namespace dht
|
|
|
|
{
|
2018-11-08 15:15:02 +00:00
|
|
|
/// acknowledgement to PublishIntroMessage or reply to FindIntroMessage
|
2018-07-11 13:20:14 +00:00
|
|
|
struct GotIntroMessage : public IMessage
|
|
|
|
{
|
2018-11-08 15:15:02 +00:00
|
|
|
/// the found introsets
|
2020-01-27 21:30:41 +00:00
|
|
|
std::vector< service::EncryptedIntroSet > found;
|
2018-11-08 15:15:02 +00:00
|
|
|
/// txid
|
2020-01-23 12:11:11 +00:00
|
|
|
uint64_t txid = 0;
|
2018-11-08 15:15:02 +00:00
|
|
|
/// the key of a router closer in keyspace if iterative lookup
|
2020-01-23 12:11:11 +00:00
|
|
|
absl::optional< Key_t > closer;
|
2018-07-11 16:11:19 +00:00
|
|
|
|
2018-07-12 13:43:37 +00:00
|
|
|
GotIntroMessage(const Key_t& from) : IMessage(from)
|
2018-07-11 16:11:19 +00:00
|
|
|
{
|
|
|
|
}
|
2018-07-11 13:20:14 +00:00
|
|
|
|
2019-05-03 13:15:03 +00:00
|
|
|
GotIntroMessage(const GotIntroMessage& other)
|
|
|
|
: IMessage(other.From)
|
2020-01-23 12:11:11 +00:00
|
|
|
, found(other.found)
|
|
|
|
, txid(other.txid)
|
|
|
|
, closer(other.closer)
|
2019-05-03 13:15:03 +00:00
|
|
|
{
|
|
|
|
version = other.version;
|
|
|
|
}
|
|
|
|
|
2018-11-08 15:15:02 +00:00
|
|
|
/// for iterative reply
|
2020-01-23 12:11:11 +00:00
|
|
|
GotIntroMessage(const Key_t& from, const Key_t& _closer, uint64_t _txid)
|
|
|
|
: IMessage(from), txid(_txid), closer(_closer)
|
2018-11-08 15:15:02 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/// for recursive reply
|
2020-01-27 21:30:41 +00:00
|
|
|
GotIntroMessage(std::vector< service::EncryptedIntroSet > results,
|
|
|
|
uint64_t txid);
|
2018-07-11 13:20:14 +00:00
|
|
|
|
2019-07-30 23:42:13 +00:00
|
|
|
~GotIntroMessage() override = default;
|
2018-07-11 13:20:14 +00:00
|
|
|
|
|
|
|
bool
|
2018-11-05 11:27:12 +00:00
|
|
|
BEncode(llarp_buffer_t* buf) const override;
|
2018-07-11 13:20:14 +00:00
|
|
|
|
|
|
|
bool
|
2019-02-05 00:41:33 +00:00
|
|
|
DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* val) override;
|
2018-07-11 13:20:14 +00:00
|
|
|
|
2019-07-30 23:42:13 +00:00
|
|
|
bool
|
2019-05-03 13:15:03 +00:00
|
|
|
HandleMessage(llarp_dht_context* ctx,
|
|
|
|
std::vector< IMessage::Ptr_t >& replies) const override;
|
2018-07-12 13:43:37 +00:00
|
|
|
};
|
|
|
|
|
2018-11-05 11:27:12 +00:00
|
|
|
struct RelayedGotIntroMessage final : public GotIntroMessage
|
2018-07-12 13:43:37 +00:00
|
|
|
{
|
|
|
|
RelayedGotIntroMessage() : GotIntroMessage({})
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-07-11 16:11:19 +00:00
|
|
|
bool
|
2019-05-03 13:15:03 +00:00
|
|
|
HandleMessage(llarp_dht_context* ctx,
|
|
|
|
std::vector< IMessage::Ptr_t >& replies) const override;
|
2018-07-11 13:20:14 +00:00
|
|
|
};
|
2019-05-03 13:15:03 +00:00
|
|
|
|
|
|
|
using GotIntroMessage_constptr = std::shared_ptr< const GotIntroMessage >;
|
2018-07-12 13:43:37 +00:00
|
|
|
} // namespace dht
|
|
|
|
} // namespace llarp
|
2018-08-29 20:40:26 +00:00
|
|
|
#endif
|