2019-04-19 16:02:32 +00:00
|
|
|
#ifndef LLARP_SERVICE_SENDCONTEXT_HPP
|
|
|
|
#define LLARP_SERVICE_SENDCONTEXT_HPP
|
2019-04-25 17:15:56 +00:00
|
|
|
#include <messages/path_transfer.hpp>
|
2019-04-19 16:02:32 +00:00
|
|
|
#include <path/pathset.hpp>
|
2019-04-22 18:35:19 +00:00
|
|
|
#include <service/intro.hpp>
|
2019-04-19 16:02:32 +00:00
|
|
|
#include <service/protocol.hpp>
|
|
|
|
#include <util/buffer.hpp>
|
|
|
|
#include <util/types.hpp>
|
2019-04-25 17:15:56 +00:00
|
|
|
#include <deque>
|
2019-04-19 16:02:32 +00:00
|
|
|
|
|
|
|
namespace llarp
|
|
|
|
{
|
|
|
|
namespace service
|
|
|
|
{
|
|
|
|
struct ServiceInfo;
|
|
|
|
struct Endpoint;
|
|
|
|
struct Introduction;
|
|
|
|
|
|
|
|
struct SendContext
|
|
|
|
{
|
|
|
|
SendContext(const ServiceInfo& ident, const Introduction& intro,
|
|
|
|
path::PathSet* send, Endpoint* ep);
|
|
|
|
|
|
|
|
void
|
|
|
|
AsyncEncryptAndSendTo(const llarp_buffer_t& payload, ProtocolType t);
|
|
|
|
|
2019-04-25 17:15:56 +00:00
|
|
|
/// queue send a fully encrypted hidden service frame
|
2019-04-23 17:35:20 +00:00
|
|
|
/// via a path
|
2019-04-19 16:02:32 +00:00
|
|
|
bool
|
2019-04-25 17:15:56 +00:00
|
|
|
Send(const ProtocolFrame& f, path::Path_ptr path)
|
|
|
|
LOCKS_EXCLUDED(m_SendQueueMutex);
|
|
|
|
|
2019-04-30 15:09:42 +00:00
|
|
|
/// flush upstream traffic when in router thread
|
2019-04-25 17:15:56 +00:00
|
|
|
void
|
2019-04-30 15:09:42 +00:00
|
|
|
FlushUpstream() LOCKS_EXCLUDED(m_SendQueueMutex);
|
2019-04-19 16:02:32 +00:00
|
|
|
|
|
|
|
SharedSecret sharedKey;
|
|
|
|
ServiceInfo remoteIdent;
|
|
|
|
Introduction remoteIntro;
|
|
|
|
ConvoTag currentConvoTag;
|
2019-04-23 17:35:20 +00:00
|
|
|
path::PathSet* const m_PathSet;
|
|
|
|
IDataHandler* const m_DataHandler;
|
|
|
|
Endpoint* const m_Endpoint;
|
2019-04-19 16:02:32 +00:00
|
|
|
uint64_t sequenceNo = 0;
|
|
|
|
llarp_time_t lastGoodSend = 0;
|
|
|
|
llarp_time_t createdAt;
|
|
|
|
llarp_time_t sendTimeout = 40 * 1000;
|
|
|
|
llarp_time_t connectTimeout = 60 * 1000;
|
|
|
|
bool markedBad = false;
|
2019-04-25 17:15:56 +00:00
|
|
|
using Msg_ptr = std::shared_ptr< const routing::PathTransferMessage >;
|
|
|
|
using SendEvent_t = std::pair< Msg_ptr, path::Path_ptr >;
|
|
|
|
util::Mutex m_SendQueueMutex;
|
|
|
|
std::deque< SendEvent_t > m_SendQueue;
|
2019-04-19 16:02:32 +00:00
|
|
|
|
|
|
|
virtual bool
|
|
|
|
ShiftIntroduction(bool rebuild = true)
|
|
|
|
{
|
|
|
|
(void)rebuild;
|
|
|
|
return true;
|
2019-04-24 23:27:31 +00:00
|
|
|
}
|
2019-04-19 16:02:32 +00:00
|
|
|
|
|
|
|
virtual void
|
|
|
|
UpdateIntroSet(bool randomizePath = false) = 0;
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
MarkCurrentIntroBad(llarp_time_t now) = 0;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void
|
|
|
|
EncryptAndSendTo(const llarp_buffer_t& payload, ProtocolType t);
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
AsyncGenIntro(const llarp_buffer_t& payload, ProtocolType t) = 0;
|
|
|
|
};
|
|
|
|
} // namespace service
|
|
|
|
} // namespace llarp
|
|
|
|
|
|
|
|
#endif
|