2023-09-29 21:00:13 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <llarp/dht/bucket.hpp>
|
|
|
|
#include <llarp/dht/node.hpp>
|
|
|
|
|
|
|
|
namespace llarp
|
|
|
|
{
|
|
|
|
struct Router;
|
|
|
|
|
|
|
|
/// This class mediates storage, retrieval, and functionality for the various types
|
|
|
|
/// of contact information that needs to be stored locally by the link manager and
|
|
|
|
/// router, like RouterContacts and introsets for example
|
|
|
|
struct Contacts
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
// TODO: why was this a shared ptr in the original implementation? revisit this
|
|
|
|
std::shared_ptr<int> timer_keepalive;
|
|
|
|
Router& _router;
|
2023-12-06 21:54:51 +00:00
|
|
|
const dht::Key_t _local_key;
|
2023-09-29 21:00:13 +00:00
|
|
|
|
|
|
|
// holds introsets for remote services
|
|
|
|
std::unique_ptr<dht::Bucket<dht::ISNode>> _introset_nodes;
|
|
|
|
|
|
|
|
public:
|
2023-12-06 21:54:51 +00:00
|
|
|
Contacts(Router& r);
|
2023-09-29 21:00:13 +00:00
|
|
|
|
|
|
|
std::optional<service::EncryptedIntroSet>
|
|
|
|
get_introset_by_location(const dht::Key_t& key) const;
|
|
|
|
|
2023-10-03 20:00:23 +00:00
|
|
|
// TODO: rename every ExtractStatus function to be uniformly snake cased
|
2023-09-29 21:00:13 +00:00
|
|
|
util::StatusObject
|
2023-10-03 20:00:23 +00:00
|
|
|
ExtractStatus() const;
|
2023-09-29 21:00:13 +00:00
|
|
|
|
|
|
|
void
|
2023-12-06 21:54:51 +00:00
|
|
|
put_intro(service::EncryptedIntroSet enc);
|
2023-09-29 21:00:13 +00:00
|
|
|
|
|
|
|
dht::Bucket<dht::ISNode>*
|
|
|
|
services() const
|
|
|
|
{
|
|
|
|
return _introset_nodes.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
Router*
|
|
|
|
router() const
|
|
|
|
{
|
|
|
|
return &_router;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace llarp
|