lokinet/llarp/service/endpoint_state.hpp

74 lines
1.7 KiB
C++
Raw Normal View History

#pragma once
#include "address.hpp"
#include "endpoint_types.hpp"
#include "lns_tracker.hpp"
#include "pendingbuffer.hpp"
#include "router_lookup_job.hpp"
#include "session.hpp"
#include <llarp/router_id.hpp>
#include <llarp/util/compare_ptr.hpp>
#include <llarp/util/decaying_hashtable.hpp>
#include <llarp/util/status.hpp>
2023-10-19 21:59:57 +00:00
#include <oxenc/variant.h>
#include <memory>
#include <queue>
#include <set>
#include <unordered_map>
2023-10-03 20:00:23 +00:00
namespace llarp::service
{
2023-10-03 20:00:23 +00:00
struct EndpointState
{
2023-10-03 20:00:23 +00:00
std::set<RouterID> snode_blacklist;
2023-10-03 20:00:23 +00:00
Router* router;
std::string key_file;
std::string name;
std::string net_NS;
bool is_exit_enabled = false;
2023-10-03 20:00:23 +00:00
PendingTrafficMap pending_traffic;
2023-10-03 20:00:23 +00:00
ConnectionMap remote_sessions;
ConnectionMap dead_sessions;
2023-10-03 20:00:23 +00:00
std::set<ConvoTag> inbound_convotags;
2023-10-03 20:00:23 +00:00
SNodeConnectionMap snode_sessions;
2023-10-03 20:00:23 +00:00
std::unordered_multimap<Address, EnsurePathCallback> pending_service_lookups;
std::unordered_map<Address, llarp_time_t> last_service_lookup_time;
2023-10-03 20:00:23 +00:00
std::unordered_map<RouterID, uint32_t> service_lookup_fails;
2023-10-03 20:00:23 +00:00
PendingRoutersMap pending_routers;
2023-10-03 20:00:23 +00:00
llarp_time_t last_publish = 0s;
llarp_time_t last_publish_attempt = 0s;
/// our introset
IntroSet local_introset;
/// on initialize functions
std::list<std::function<bool(void)>> on_init_callbacks;
2023-10-03 20:00:23 +00:00
/// conversations
std::unordered_map<ConvoTag, Session> m_Sessions;
2023-10-03 20:00:23 +00:00
std::unordered_set<Address> m_OutboundSessions;
2020-02-18 16:00:45 +00:00
2023-10-03 20:00:23 +00:00
util::DecayingHashTable<std::string, std::variant<Address, RouterID>, std::hash<std::string>>
nameCache;
2023-10-03 20:00:23 +00:00
LNSLookupTracker lnsTracker;
2023-10-03 20:00:23 +00:00
bool
Configure(const NetworkConfig& conf);
2023-10-03 20:00:23 +00:00
util::StatusObject
ExtractStatus(util::StatusObject& obj) const;
};
} // namespace llarp::service