2019-07-15 09:15:51 +00:00
|
|
|
#ifndef LLARP_SERVICE_ENDPOINT_STATE_HPP
|
|
|
|
#define LLARP_SERVICE_ENDPOINT_STATE_HPP
|
|
|
|
|
|
|
|
#include <hook/ihook.hpp>
|
|
|
|
#include <router_id.hpp>
|
|
|
|
#include <service/address.hpp>
|
|
|
|
#include <service/pendingbuffer.hpp>
|
|
|
|
#include <service/router_lookup_job.hpp>
|
|
|
|
#include <service/session.hpp>
|
|
|
|
#include <service/tag_lookup_job.hpp>
|
|
|
|
#include <service/endpoint_types.hpp>
|
|
|
|
#include <util/compare_ptr.hpp>
|
|
|
|
#include <util/status.hpp>
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <queue>
|
|
|
|
#include <set>
|
|
|
|
#include <unordered_map>
|
|
|
|
|
|
|
|
struct llarp_ev_loop;
|
2020-04-07 18:38:56 +00:00
|
|
|
using llarp_ev_loop_ptr = std::shared_ptr<llarp_ev_loop>;
|
2019-07-15 09:15:51 +00:00
|
|
|
|
|
|
|
namespace llarp
|
|
|
|
{
|
|
|
|
// clang-format off
|
|
|
|
namespace exit { struct BaseSession; }
|
|
|
|
namespace path { struct Path; using Path_ptr = std::shared_ptr< Path >; }
|
|
|
|
namespace routing { struct PathTransferMessage; }
|
|
|
|
// clang-format on
|
|
|
|
|
|
|
|
namespace service
|
|
|
|
{
|
|
|
|
struct IServiceLookup;
|
|
|
|
struct OutboundContext;
|
2019-07-18 16:28:17 +00:00
|
|
|
struct Endpoint;
|
2019-07-15 09:15:51 +00:00
|
|
|
|
|
|
|
struct EndpointState
|
|
|
|
{
|
|
|
|
hooks::Backend_ptr m_OnUp;
|
|
|
|
hooks::Backend_ptr m_OnDown;
|
|
|
|
hooks::Backend_ptr m_OnReady;
|
|
|
|
|
2020-04-07 18:38:56 +00:00
|
|
|
std::set<RouterID> m_SnodeBlacklist;
|
2019-07-15 09:15:51 +00:00
|
|
|
|
|
|
|
AbstractRouter* m_Router;
|
2020-04-07 18:38:56 +00:00
|
|
|
std::shared_ptr<Logic> m_IsolatedLogic = nullptr;
|
|
|
|
llarp_ev_loop_ptr m_IsolatedNetLoop = nullptr;
|
2019-07-15 09:15:51 +00:00
|
|
|
std::string m_Keyfile;
|
|
|
|
std::string m_Name;
|
|
|
|
std::string m_NetNS;
|
2020-05-21 14:18:23 +00:00
|
|
|
bool m_ExitEnabled = false;
|
2019-07-15 09:15:51 +00:00
|
|
|
|
|
|
|
PendingTraffic m_PendingTraffic;
|
|
|
|
|
|
|
|
Sessions m_RemoteSessions;
|
|
|
|
Sessions m_DeadSessions;
|
|
|
|
|
2020-04-07 18:38:56 +00:00
|
|
|
std::set<ConvoTag> m_InboundConvos;
|
2019-07-15 09:15:51 +00:00
|
|
|
|
|
|
|
SNodeSessions m_SNodeSessions;
|
|
|
|
|
2020-04-07 18:38:56 +00:00
|
|
|
std::unordered_multimap<Address, PathEnsureHook, Address::Hash> m_PendingServiceLookups;
|
2020-08-31 20:07:17 +00:00
|
|
|
std::unordered_map<Address, llarp_time_t, Address::Hash> m_LastServiceLookupTimes;
|
2019-07-15 09:15:51 +00:00
|
|
|
|
2020-04-07 18:38:56 +00:00
|
|
|
std::unordered_map<RouterID, uint32_t, RouterID::Hash> m_ServiceLookupFails;
|
2019-07-15 09:15:51 +00:00
|
|
|
|
|
|
|
PendingRouters m_PendingRouters;
|
|
|
|
|
2020-04-07 18:38:56 +00:00
|
|
|
llarp_time_t m_LastPublish = 0s;
|
2020-02-24 19:40:45 +00:00
|
|
|
llarp_time_t m_LastPublishAttempt = 0s;
|
2019-07-15 09:15:51 +00:00
|
|
|
/// our introset
|
|
|
|
IntroSet m_IntroSet;
|
|
|
|
/// pending remote service lookups by id
|
|
|
|
PendingLookups m_PendingLookups;
|
|
|
|
/// on initialize functions
|
2020-04-07 18:38:56 +00:00
|
|
|
std::list<std::function<bool(void)>> m_OnInit;
|
2019-07-15 09:15:51 +00:00
|
|
|
|
|
|
|
/// conversations
|
|
|
|
ConvoMap m_Sessions;
|
|
|
|
|
2020-02-18 16:00:45 +00:00
|
|
|
OutboundSessions_t m_OutboundSessions;
|
|
|
|
|
2020-04-07 18:38:56 +00:00
|
|
|
std::unordered_map<Tag, CachedTagResult, Tag::Hash> m_PrefetchedTags;
|
2019-07-15 09:15:51 +00:00
|
|
|
|
|
|
|
bool
|
2020-04-30 22:11:05 +00:00
|
|
|
Configure(const NetworkConfig& conf);
|
2019-07-15 09:15:51 +00:00
|
|
|
|
|
|
|
util::StatusObject
|
|
|
|
ExtractStatus(util::StatusObject& obj) const;
|
|
|
|
};
|
|
|
|
} // namespace service
|
|
|
|
} // namespace llarp
|
|
|
|
|
|
|
|
#endif
|