2018-07-09 19:32:11 +02:00
|
|
|
#ifndef LLARP_SERVICE_ENDPOINT_HPP
|
|
|
|
#define LLARP_SERVICE_ENDPOINT_HPP
|
2018-12-12 03:15:08 +01:00
|
|
|
|
2019-05-09 22:28:56 +02:00
|
|
|
#include <dht/messages/gotrouter.hpp>
|
2019-01-11 02:19:36 +01:00
|
|
|
#include <ev/ev.h>
|
2018-12-12 02:06:46 +01:00
|
|
|
#include <exit/session.hpp>
|
2019-01-11 02:42:02 +01:00
|
|
|
#include <net/net.hpp>
|
2019-01-11 02:19:36 +01:00
|
|
|
#include <path/path.hpp>
|
|
|
|
#include <path/pathbuilder.hpp>
|
2019-01-07 23:15:31 +01:00
|
|
|
#include <service/address.hpp>
|
2018-12-12 03:15:08 +01:00
|
|
|
#include <service/handler.hpp>
|
2019-04-22 20:35:19 +02:00
|
|
|
#include <service/identity.hpp>
|
2019-04-19 18:02:32 +02:00
|
|
|
#include <service/pendingbuffer.hpp>
|
2018-12-12 03:15:08 +01:00
|
|
|
#include <service/protocol.hpp>
|
2019-04-21 19:41:58 +02:00
|
|
|
#include <service/sendcontext.hpp>
|
2019-04-21 20:38:30 +02:00
|
|
|
#include <service/session.hpp>
|
2019-04-21 19:41:58 +02:00
|
|
|
#include <service/tag_lookup_job.hpp>
|
2019-04-22 14:25:25 +02:00
|
|
|
#include <hook/ihook.hpp>
|
2018-07-09 19:32:11 +02:00
|
|
|
|
2019-03-29 02:02:41 +01:00
|
|
|
// minimum time between introset shifts
|
2018-09-18 19:48:26 +02:00
|
|
|
#ifndef MIN_SHIFT_INTERVAL
|
|
|
|
#define MIN_SHIFT_INTERVAL (5 * 1000)
|
|
|
|
#endif
|
|
|
|
|
2019-05-09 22:28:56 +02:00
|
|
|
struct llarp_async_verify_rc;
|
|
|
|
|
2018-07-09 19:32:11 +02:00
|
|
|
namespace llarp
|
|
|
|
{
|
|
|
|
namespace service
|
|
|
|
{
|
2018-09-14 15:43:42 +02:00
|
|
|
struct AsyncKeyExchange;
|
2019-04-21 18:44:27 +02:00
|
|
|
struct Context;
|
|
|
|
struct OutboundContext;
|
2018-09-14 15:43:42 +02:00
|
|
|
|
2018-08-30 20:48:43 +02:00
|
|
|
struct Endpoint : public path::Builder,
|
2018-08-09 21:02:17 +02:00
|
|
|
public ILookupHolder,
|
|
|
|
public IDataHandler
|
2018-07-09 19:32:11 +02:00
|
|
|
{
|
2018-07-18 05:10:21 +02:00
|
|
|
/// minimum interval for publishing introsets
|
|
|
|
static const llarp_time_t INTROSET_PUBLISH_INTERVAL =
|
2019-04-05 16:58:22 +02:00
|
|
|
path::default_lifetime / 8;
|
2018-07-18 05:10:21 +02:00
|
|
|
|
|
|
|
static const llarp_time_t INTROSET_PUBLISH_RETRY_INTERVAL = 5000;
|
|
|
|
|
2018-09-28 14:22:50 +02:00
|
|
|
static const size_t MAX_OUTBOUND_CONTEXT_COUNT = 4;
|
|
|
|
|
2019-02-11 20:45:42 +01:00
|
|
|
Endpoint(const std::string& nickname, AbstractRouter* r, Context* parent);
|
2018-07-09 19:32:11 +02:00
|
|
|
~Endpoint();
|
|
|
|
|
2019-04-22 14:25:25 +02:00
|
|
|
/// return true if we are ready to recv packets from the void
|
|
|
|
bool
|
|
|
|
IsReady() const;
|
|
|
|
|
|
|
|
/// return true if our introset has expired intros
|
|
|
|
bool
|
|
|
|
IntrosetIsStale() const;
|
|
|
|
|
|
|
|
/// construct parameters for notify hooks
|
2019-04-22 16:00:59 +02:00
|
|
|
virtual std::unordered_map< std::string, std::string >
|
2019-04-22 14:25:25 +02:00
|
|
|
NotifyParams() const;
|
|
|
|
|
2019-04-19 17:10:26 +02:00
|
|
|
util::StatusObject
|
|
|
|
ExtractStatus() const;
|
2019-02-08 20:43:25 +01:00
|
|
|
|
2018-08-08 21:37:33 +02:00
|
|
|
void
|
|
|
|
SetHandler(IDataHandler* h);
|
|
|
|
|
2018-08-16 16:34:15 +02:00
|
|
|
virtual bool
|
2018-07-09 19:32:11 +02:00
|
|
|
SetOption(const std::string& k, const std::string& v);
|
|
|
|
|
2018-08-16 16:34:15 +02:00
|
|
|
virtual void
|
2019-04-23 18:13:22 +02:00
|
|
|
Tick(llarp_time_t now) override;
|
2018-07-11 18:11:19 +02:00
|
|
|
|
2019-01-28 16:26:35 +01:00
|
|
|
/// return true if we have a resolvable ip address
|
|
|
|
virtual bool
|
|
|
|
HasIfAddr() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// get our ifaddr if it is set
|
|
|
|
virtual huint32_t
|
|
|
|
GetIfAddr() const
|
|
|
|
{
|
|
|
|
return huint32_t{0};
|
|
|
|
}
|
|
|
|
|
2019-05-07 19:46:38 +02:00
|
|
|
virtual void
|
|
|
|
ResetInternalState() override;
|
|
|
|
|
2018-08-09 21:02:17 +02:00
|
|
|
/// router's logic
|
2019-04-23 16:28:59 +02:00
|
|
|
/// use when sending any data on a path
|
2019-04-21 20:38:30 +02:00
|
|
|
Logic*
|
2018-08-09 21:02:17 +02:00
|
|
|
RouterLogic();
|
|
|
|
|
|
|
|
/// endpoint's logic
|
2019-04-23 16:28:59 +02:00
|
|
|
/// use when writing any data to local network interfaces
|
2019-04-21 20:38:30 +02:00
|
|
|
Logic*
|
2018-08-09 21:02:17 +02:00
|
|
|
EndpointLogic();
|
2018-07-19 06:58:39 +02:00
|
|
|
|
2019-04-23 18:13:22 +02:00
|
|
|
/// borrow endpoint's net loop for sending data to user on local network
|
|
|
|
/// interface
|
2019-04-08 14:01:52 +02:00
|
|
|
llarp_ev_loop_ptr
|
2018-08-17 21:49:58 +02:00
|
|
|
EndpointNetLoop();
|
|
|
|
|
2019-04-21 20:38:30 +02:00
|
|
|
Crypto*
|
2019-04-28 17:57:41 +02:00
|
|
|
crypto();
|
2018-07-19 06:58:39 +02:00
|
|
|
|
2019-04-23 16:28:59 +02:00
|
|
|
/// crypto worker threadpool
|
2018-07-19 06:58:39 +02:00
|
|
|
llarp_threadpool*
|
2019-04-23 16:28:59 +02:00
|
|
|
CryptoWorker();
|
2018-07-19 06:58:39 +02:00
|
|
|
|
2019-02-11 20:45:42 +01:00
|
|
|
AbstractRouter*
|
2018-07-23 01:14:29 +02:00
|
|
|
Router()
|
|
|
|
{
|
|
|
|
return m_Router;
|
|
|
|
}
|
|
|
|
|
2019-01-16 22:12:24 +01:00
|
|
|
virtual bool
|
|
|
|
LoadKeyFile();
|
|
|
|
|
2018-08-16 16:34:15 +02:00
|
|
|
virtual bool
|
2018-07-09 19:32:11 +02:00
|
|
|
Start();
|
|
|
|
|
2018-11-12 17:43:40 +01:00
|
|
|
virtual std::string
|
2019-03-25 02:54:37 +01:00
|
|
|
Name() const override;
|
2018-07-16 05:32:13 +02:00
|
|
|
|
2018-07-18 05:10:21 +02:00
|
|
|
bool
|
2018-12-24 22:10:35 +01:00
|
|
|
ShouldPublishDescriptors(llarp_time_t now) const override;
|
2018-07-18 05:10:21 +02:00
|
|
|
|
2019-03-30 14:02:10 +01:00
|
|
|
void
|
2019-04-23 16:28:59 +02:00
|
|
|
HandlePathDied(path::Path_ptr p) override;
|
2019-03-30 14:02:10 +01:00
|
|
|
|
2018-09-14 15:43:42 +02:00
|
|
|
void
|
|
|
|
EnsureReplyPath(const ServiceInfo& addr);
|
|
|
|
|
2018-07-18 05:10:21 +02:00
|
|
|
bool
|
2019-02-11 20:45:42 +01:00
|
|
|
PublishIntroSet(AbstractRouter* r) override;
|
2018-07-18 05:10:21 +02:00
|
|
|
|
2018-09-18 16:48:06 +02:00
|
|
|
bool
|
2019-04-23 16:28:59 +02:00
|
|
|
PublishIntroSetVia(AbstractRouter* r, path::Path_ptr p);
|
2018-09-18 16:48:06 +02:00
|
|
|
|
2018-07-11 18:11:19 +02:00
|
|
|
bool
|
2019-05-03 15:15:03 +02:00
|
|
|
HandleGotIntroMessage(
|
|
|
|
std::shared_ptr< const dht::GotIntroMessage > msg) override;
|
2018-07-11 18:11:19 +02:00
|
|
|
|
2018-08-10 23:34:11 +02:00
|
|
|
bool
|
2019-05-03 15:15:03 +02:00
|
|
|
HandleGotRouterMessage(
|
|
|
|
std::shared_ptr< const dht::GotRouterMessage > msg) override;
|
2018-08-10 23:34:11 +02:00
|
|
|
|
2018-07-12 20:21:44 +02:00
|
|
|
bool
|
2019-04-23 16:28:59 +02:00
|
|
|
HandleHiddenServiceFrame(path::Path_ptr p,
|
2019-04-22 19:38:29 +02:00
|
|
|
const service::ProtocolFrame& msg);
|
2018-07-12 20:21:44 +02:00
|
|
|
|
2018-10-23 20:06:55 +02:00
|
|
|
virtual huint32_t
|
2019-01-02 02:03:53 +01:00
|
|
|
ObtainIPForAddr(const AlignedBuffer< 32 >& addr, bool serviceNode) = 0;
|
2018-10-23 20:06:55 +02:00
|
|
|
|
2018-10-23 20:18:00 +02:00
|
|
|
virtual bool
|
2019-01-02 02:04:04 +01:00
|
|
|
HasAddress(const AlignedBuffer< 32 >& addr) const = 0;
|
2018-11-07 16:30:22 +01:00
|
|
|
|
2018-08-10 05:51:38 +02:00
|
|
|
/// return true if we have a pending job to build to a hidden service but
|
|
|
|
/// it's not done yet
|
|
|
|
bool
|
|
|
|
HasPendingPathToService(const Address& remote) const;
|
|
|
|
|
2018-07-12 20:21:44 +02:00
|
|
|
/// return false if we don't have a path to the service
|
|
|
|
/// return true if we did and we removed it
|
|
|
|
bool
|
|
|
|
ForgetPathToService(const Address& remote);
|
|
|
|
|
2018-09-18 19:48:26 +02:00
|
|
|
bool
|
2019-05-03 15:15:03 +02:00
|
|
|
HandleDataMessage(const PathID_t&,
|
|
|
|
std::shared_ptr< ProtocolMessage > msg) override;
|
2018-08-09 21:02:17 +02:00
|
|
|
|
2018-12-02 19:07:07 +01:00
|
|
|
virtual bool
|
2019-02-01 02:58:06 +01:00
|
|
|
HandleWriteIPPacket(const llarp_buffer_t& pkt,
|
2018-12-02 19:07:07 +01:00
|
|
|
std::function< huint32_t(void) > getFromIP) = 0;
|
2018-11-29 14:12:35 +01:00
|
|
|
|
|
|
|
bool
|
2019-05-03 15:15:03 +02:00
|
|
|
ProcessDataMessage(std::shared_ptr< ProtocolMessage > msg);
|
2018-09-18 19:48:26 +02:00
|
|
|
|
2018-08-10 23:34:11 +02:00
|
|
|
/// ensure that we know a router, looks up if it doesn't
|
|
|
|
void
|
|
|
|
EnsureRouterIsKnown(const RouterID& router);
|
|
|
|
|
2018-12-24 17:09:05 +01:00
|
|
|
/// lookup a router via closest path
|
|
|
|
bool
|
2019-05-03 15:15:03 +02:00
|
|
|
LookupRouterAnon(RouterID router, RouterLookupHandler handler);
|
2018-12-24 17:09:05 +01:00
|
|
|
|
2019-04-25 19:15:56 +02:00
|
|
|
/// called on event loop pump
|
|
|
|
virtual void
|
|
|
|
Pump(llarp_time_t now);
|
|
|
|
|
2018-12-24 17:09:05 +01:00
|
|
|
/// stop this endpoint
|
|
|
|
bool
|
|
|
|
Stop() override;
|
|
|
|
|
2018-08-14 01:22:31 +02:00
|
|
|
const Identity&
|
2018-11-21 15:30:14 +01:00
|
|
|
GetIdentity() const
|
2018-07-23 01:14:29 +02:00
|
|
|
{
|
2018-08-14 01:22:31 +02:00
|
|
|
return m_Identity;
|
2018-07-23 01:14:29 +02:00
|
|
|
}
|
2018-07-19 06:58:39 +02:00
|
|
|
|
2018-08-04 04:59:32 +02:00
|
|
|
void
|
2018-12-24 22:10:35 +01:00
|
|
|
PutLookup(IServiceLookup* lookup, uint64_t txid) override;
|
2018-08-04 04:59:32 +02:00
|
|
|
|
2018-08-02 02:48:43 +02:00
|
|
|
void
|
2019-04-23 16:28:59 +02:00
|
|
|
HandlePathBuilt(path::Path_ptr path) override;
|
2018-08-02 02:48:43 +02:00
|
|
|
|
2018-08-22 17:52:10 +02:00
|
|
|
bool
|
2019-02-01 02:58:06 +01:00
|
|
|
SendToServiceOrQueue(const RouterID& addr, const llarp_buffer_t& payload,
|
2018-12-02 19:07:07 +01:00
|
|
|
ProtocolType t);
|
2018-11-29 14:12:35 +01:00
|
|
|
|
|
|
|
bool
|
2019-02-01 02:58:06 +01:00
|
|
|
SendToSNodeOrQueue(const RouterID& addr, const llarp_buffer_t& payload);
|
2018-08-22 17:52:10 +02:00
|
|
|
|
2018-09-11 17:28:36 +02:00
|
|
|
bool
|
2019-04-23 16:28:59 +02:00
|
|
|
HandleDataDrop(path::Path_ptr p, const PathID_t& dst, uint64_t s);
|
2018-09-11 17:28:36 +02:00
|
|
|
|
2018-09-13 14:27:28 +02:00
|
|
|
bool
|
2019-04-23 16:28:59 +02:00
|
|
|
CheckPathIsDead(path::Path_ptr p, llarp_time_t latency);
|
2018-09-13 14:27:28 +02:00
|
|
|
|
2019-04-30 18:49:34 +02:00
|
|
|
using PendingBufferQueue = std::deque< PendingBuffer >;
|
2018-08-22 17:52:10 +02:00
|
|
|
|
2019-04-18 13:49:54 +02:00
|
|
|
bool
|
|
|
|
ShouldBundleRC() const override;
|
|
|
|
|
2018-09-17 17:32:37 +02:00
|
|
|
static void
|
|
|
|
HandlePathDead(void*);
|
|
|
|
|
2019-03-08 18:00:13 +01:00
|
|
|
bool
|
|
|
|
HasConvoTag(const ConvoTag& t) const override;
|
|
|
|
|
2019-03-08 15:36:24 +01:00
|
|
|
bool
|
|
|
|
ShouldBuildMore(llarp_time_t now) const override;
|
|
|
|
|
2018-07-12 20:21:44 +02:00
|
|
|
// passed a sendto context when we have a path established otherwise
|
|
|
|
// nullptr if the path was not made before the timeout
|
2018-11-23 00:59:03 +01:00
|
|
|
using PathEnsureHook = std::function< void(Address, OutboundContext*) >;
|
2018-07-12 20:21:44 +02:00
|
|
|
|
|
|
|
/// return false if we have already called this function before for this
|
|
|
|
/// address
|
|
|
|
bool
|
|
|
|
EnsurePathToService(const Address& remote, PathEnsureHook h,
|
2018-10-23 20:06:55 +02:00
|
|
|
uint64_t timeoutMS, bool lookupOnRandomPath = false);
|
2018-07-12 20:21:44 +02:00
|
|
|
|
2018-12-02 19:07:07 +01:00
|
|
|
using SNodeEnsureHook =
|
2019-04-23 18:13:22 +02:00
|
|
|
std::function< void(RouterID, exit::BaseSession_ptr) >;
|
2018-11-29 14:12:35 +01:00
|
|
|
|
|
|
|
/// ensure a path to a service node by public key
|
|
|
|
void
|
2019-03-01 20:10:42 +01:00
|
|
|
EnsurePathToSNode(const RouterID& remote, SNodeEnsureHook h);
|
2018-11-29 14:12:35 +01:00
|
|
|
|
|
|
|
bool
|
2018-12-02 19:07:07 +01:00
|
|
|
HasPathToSNode(const RouterID& remote) const;
|
2018-11-29 14:12:35 +01:00
|
|
|
|
2018-08-09 21:02:17 +02:00
|
|
|
void
|
2018-12-24 22:10:35 +01:00
|
|
|
PutSenderFor(const ConvoTag& tag, const ServiceInfo& info) override;
|
2018-08-09 21:02:17 +02:00
|
|
|
|
|
|
|
bool
|
|
|
|
GetCachedSessionKeyFor(const ConvoTag& remote,
|
2019-01-02 02:04:04 +01:00
|
|
|
SharedSecret& secret) const override;
|
2018-08-09 21:02:17 +02:00
|
|
|
void
|
|
|
|
PutCachedSessionKeyFor(const ConvoTag& remote,
|
2018-12-24 22:10:35 +01:00
|
|
|
const SharedSecret& secret) override;
|
2018-08-09 21:02:17 +02:00
|
|
|
|
|
|
|
bool
|
2018-12-24 22:10:35 +01:00
|
|
|
GetSenderFor(const ConvoTag& remote, ServiceInfo& si) const override;
|
2018-08-09 21:02:17 +02:00
|
|
|
|
|
|
|
void
|
2018-12-24 22:10:35 +01:00
|
|
|
PutIntroFor(const ConvoTag& remote, const Introduction& intro) override;
|
2018-08-09 21:02:17 +02:00
|
|
|
|
|
|
|
bool
|
2018-12-24 22:10:35 +01:00
|
|
|
GetIntroFor(const ConvoTag& remote, Introduction& intro) const override;
|
2018-08-09 21:02:17 +02:00
|
|
|
|
2019-03-08 17:00:45 +01:00
|
|
|
void
|
|
|
|
RemoveConvoTag(const ConvoTag& remote) override;
|
|
|
|
|
2019-02-21 17:45:33 +01:00
|
|
|
void
|
|
|
|
PutReplyIntroFor(const ConvoTag& remote,
|
|
|
|
const Introduction& intro) override;
|
|
|
|
|
|
|
|
bool
|
|
|
|
GetReplyIntroFor(const ConvoTag& remote,
|
|
|
|
Introduction& intro) const override;
|
|
|
|
|
2018-08-09 21:02:17 +02:00
|
|
|
bool
|
|
|
|
GetConvoTagsForService(const ServiceInfo& si,
|
2018-12-24 22:10:35 +01:00
|
|
|
std::set< ConvoTag >& tag) const override;
|
2018-08-09 21:02:17 +02:00
|
|
|
|
2018-07-19 23:08:11 +02:00
|
|
|
void
|
|
|
|
PutNewOutboundContext(const IntroSet& introset);
|
|
|
|
|
2019-04-19 18:02:32 +02:00
|
|
|
uint64_t
|
|
|
|
GetSeqNoForConvo(const ConvoTag& tag);
|
|
|
|
|
2018-07-18 05:10:21 +02:00
|
|
|
virtual void
|
|
|
|
IntroSetPublishFail();
|
|
|
|
virtual void
|
|
|
|
IntroSetPublished();
|
|
|
|
|
2019-04-21 18:44:27 +02:00
|
|
|
uint64_t
|
|
|
|
GenTXID();
|
|
|
|
|
2018-09-18 16:48:06 +02:00
|
|
|
protected:
|
2019-01-28 16:26:35 +01:00
|
|
|
/// parent context that owns this endpoint
|
|
|
|
Context* const context;
|
|
|
|
|
2018-09-11 15:21:35 +02:00
|
|
|
void
|
2018-10-01 16:18:17 +02:00
|
|
|
RegenAndPublishIntroSet(llarp_time_t now, bool forceRebuild = false);
|
2018-09-11 15:21:35 +02:00
|
|
|
|
2018-07-18 05:10:21 +02:00
|
|
|
IServiceLookup*
|
|
|
|
GenerateLookupByTag(const Tag& tag);
|
|
|
|
|
|
|
|
void
|
|
|
|
PrefetchServicesByTag(const Tag& tag);
|
|
|
|
|
2018-08-09 21:02:17 +02:00
|
|
|
bool
|
|
|
|
IsolateNetwork();
|
|
|
|
|
2018-08-16 16:34:15 +02:00
|
|
|
bool
|
|
|
|
NetworkIsIsolated() const;
|
|
|
|
|
2018-08-17 21:49:58 +02:00
|
|
|
static void
|
|
|
|
RunIsolatedMainLoop(void*);
|
|
|
|
|
2018-07-18 05:10:21 +02:00
|
|
|
private:
|
2019-05-09 22:28:56 +02:00
|
|
|
void
|
|
|
|
HandleVerifyGotRouter(dht::GotRouterMessage_constptr msg,
|
|
|
|
llarp_async_verify_rc* j);
|
|
|
|
|
2018-08-10 23:34:11 +02:00
|
|
|
bool
|
2018-10-15 17:43:41 +02:00
|
|
|
OnLookup(const service::Address& addr, const IntroSet* i,
|
|
|
|
const RouterID& endpoint); /* */
|
2018-08-10 23:34:11 +02:00
|
|
|
|
2018-08-09 21:02:17 +02:00
|
|
|
static bool
|
2018-08-20 21:12:12 +02:00
|
|
|
SetupIsolatedNetwork(void* user, bool success);
|
2018-08-09 21:02:17 +02:00
|
|
|
|
|
|
|
bool
|
2018-08-18 16:01:21 +02:00
|
|
|
DoNetworkIsolation(bool failed);
|
2018-08-09 21:02:17 +02:00
|
|
|
|
2018-08-16 16:34:15 +02:00
|
|
|
virtual bool
|
|
|
|
SetupNetworking()
|
|
|
|
{
|
|
|
|
// XXX: override me
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-08-18 16:01:21 +02:00
|
|
|
virtual bool
|
|
|
|
IsolationFailed()
|
|
|
|
{
|
|
|
|
// XXX: override me
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-08-08 21:37:33 +02:00
|
|
|
protected:
|
|
|
|
IDataHandler* m_DataHandler = nullptr;
|
2018-08-09 21:02:17 +02:00
|
|
|
Identity m_Identity;
|
2019-04-23 18:13:22 +02:00
|
|
|
std::shared_ptr< exit::BaseSession > m_Exit;
|
2019-04-22 14:25:25 +02:00
|
|
|
hooks::Backend_ptr m_OnUp;
|
|
|
|
hooks::Backend_ptr m_OnDown;
|
|
|
|
hooks::Backend_ptr m_OnReady;
|
2018-08-08 21:37:33 +02:00
|
|
|
|
2018-07-09 19:32:11 +02:00
|
|
|
private:
|
2019-04-30 03:06:20 +02:00
|
|
|
friend struct EndpointUtil;
|
|
|
|
|
2018-08-14 23:17:18 +02:00
|
|
|
struct RouterLookupJob
|
|
|
|
{
|
2019-05-03 15:15:03 +02:00
|
|
|
RouterLookupJob(Endpoint* p, RouterLookupHandler h) : handler(h)
|
2018-08-14 23:17:18 +02:00
|
|
|
{
|
2018-10-29 17:48:36 +01:00
|
|
|
started = p->Now();
|
2018-08-14 23:17:18 +02:00
|
|
|
txid = p->GenTXID();
|
|
|
|
}
|
|
|
|
|
2019-05-03 15:15:03 +02:00
|
|
|
RouterLookupHandler handler;
|
2018-08-14 23:17:18 +02:00
|
|
|
uint64_t txid;
|
|
|
|
llarp_time_t started;
|
|
|
|
|
|
|
|
bool
|
|
|
|
IsExpired(llarp_time_t now) const
|
|
|
|
{
|
|
|
|
if(now < started)
|
|
|
|
return false;
|
2019-05-09 22:28:56 +02:00
|
|
|
return now - started > 30000;
|
2018-08-14 23:17:18 +02:00
|
|
|
}
|
2019-05-03 15:15:03 +02:00
|
|
|
|
|
|
|
void
|
2019-05-09 22:28:56 +02:00
|
|
|
InformResult(std::vector< RouterContact > result)
|
2019-05-03 15:15:03 +02:00
|
|
|
{
|
|
|
|
if(handler)
|
|
|
|
handler(result);
|
|
|
|
}
|
2018-08-14 23:17:18 +02:00
|
|
|
};
|
|
|
|
|
2019-05-07 10:29:47 +02:00
|
|
|
using Msg_ptr = std::shared_ptr< const routing::PathTransferMessage >;
|
|
|
|
using SendEvent_t = std::pair< Msg_ptr, path::Path_ptr >;
|
|
|
|
using PendingTraffic =
|
|
|
|
std::unordered_map< Address, PendingBufferQueue, Address::Hash >;
|
|
|
|
|
2019-04-30 03:06:20 +02:00
|
|
|
using PendingRouters =
|
|
|
|
std::unordered_map< RouterID, RouterLookupJob, RouterID::Hash >;
|
2019-05-07 10:29:47 +02:00
|
|
|
|
|
|
|
using PendingLookups =
|
|
|
|
std::unordered_map< uint64_t,
|
|
|
|
std::unique_ptr< service::IServiceLookup > >;
|
|
|
|
|
|
|
|
using Sessions =
|
|
|
|
std::unordered_multimap< Address, std::shared_ptr< OutboundContext >,
|
|
|
|
Address::Hash >;
|
|
|
|
|
|
|
|
using SNodeSessions = std::unordered_multimap<
|
|
|
|
RouterID, std::shared_ptr< exit::BaseSession >, RouterID::Hash >;
|
|
|
|
|
|
|
|
using ConvoMap = std::unordered_map< ConvoTag, Session, ConvoTag::Hash >;
|
|
|
|
|
|
|
|
AbstractRouter* m_Router;
|
|
|
|
llarp_threadpool* m_IsolatedWorker = nullptr;
|
|
|
|
Logic* m_IsolatedLogic = nullptr;
|
|
|
|
llarp_ev_loop_ptr m_IsolatedNetLoop = nullptr;
|
|
|
|
std::string m_Keyfile;
|
|
|
|
std::string m_Name;
|
|
|
|
std::string m_NetNS;
|
|
|
|
bool m_BundleRC = false;
|
|
|
|
|
|
|
|
util::Mutex m_SendQueueMutex;
|
|
|
|
std::deque< SendEvent_t > m_SendQueue GUARDED_BY(m_SendQueueMutex);
|
|
|
|
|
|
|
|
PendingTraffic m_PendingTraffic;
|
|
|
|
|
|
|
|
Sessions m_RemoteSessions;
|
|
|
|
Sessions m_DeadSessions;
|
|
|
|
|
|
|
|
SNodeSessions m_SNodeSessions;
|
|
|
|
|
|
|
|
std::unordered_map< Address, ServiceInfo, Address::Hash >
|
|
|
|
m_AddressToService;
|
|
|
|
|
|
|
|
std::unordered_multimap< Address, PathEnsureHook, Address::Hash >
|
|
|
|
m_PendingServiceLookups;
|
|
|
|
|
|
|
|
std::unordered_map< RouterID, uint32_t, RouterID::Hash >
|
|
|
|
m_ServiceLookupFails;
|
|
|
|
|
2019-04-30 03:06:20 +02:00
|
|
|
PendingRouters m_PendingRouters;
|
2018-08-10 23:34:11 +02:00
|
|
|
|
2018-07-18 05:10:21 +02:00
|
|
|
uint64_t m_CurrentPublishTX = 0;
|
|
|
|
llarp_time_t m_LastPublish = 0;
|
|
|
|
llarp_time_t m_LastPublishAttempt = 0;
|
2018-10-04 18:48:26 +02:00
|
|
|
llarp_time_t m_MinPathLatency = (5 * 1000);
|
2018-07-18 05:10:21 +02:00
|
|
|
/// our introset
|
|
|
|
service::IntroSet m_IntroSet;
|
2018-07-19 23:08:11 +02:00
|
|
|
/// pending remote service lookups by id
|
2019-04-30 03:06:20 +02:00
|
|
|
PendingLookups m_PendingLookups;
|
2018-08-02 02:48:43 +02:00
|
|
|
/// prefetch remote address list
|
|
|
|
std::set< Address > m_PrefetchAddrs;
|
2018-07-18 05:10:21 +02:00
|
|
|
/// hidden service tag
|
|
|
|
Tag m_Tag;
|
|
|
|
/// prefetch descriptors for these hidden service tags
|
|
|
|
std::set< Tag > m_PrefetchTags;
|
2018-08-09 21:02:17 +02:00
|
|
|
/// on initialize functions
|
|
|
|
std::list< std::function< bool(void) > > m_OnInit;
|
|
|
|
|
2019-02-09 16:26:20 +01:00
|
|
|
/// conversations
|
2019-04-30 03:06:20 +02:00
|
|
|
ConvoMap m_Sessions;
|
2018-07-18 05:10:21 +02:00
|
|
|
|
|
|
|
std::unordered_map< Tag, CachedTagResult, Tag::Hash > m_PrefetchedTags;
|
2018-07-09 19:32:11 +02:00
|
|
|
};
|
2019-04-23 16:47:23 +02:00
|
|
|
|
2019-04-23 18:13:22 +02:00
|
|
|
using Endpoint_ptr = std::shared_ptr< Endpoint >;
|
2019-04-23 16:47:23 +02:00
|
|
|
|
2018-07-09 19:32:11 +02:00
|
|
|
} // namespace service
|
|
|
|
} // namespace llarp
|
|
|
|
|
2018-08-16 16:34:15 +02:00
|
|
|
#endif
|