use SendBufferQueue for queued messages from I2P

This commit is contained in:
orignal 2020-11-29 14:59:34 -05:00
parent ff971563db
commit 746f53ba07
4 changed files with 75 additions and 67 deletions

View file

@ -17,6 +17,7 @@
#include <boost/asio.hpp>
#include "util.h"
#include "Destination.h"
#include "Streaming.h"
namespace i2p
{
@ -25,7 +26,7 @@ namespace client
const uint8_t I2CP_PROTOCOL_BYTE = 0x2A;
const size_t I2CP_SESSION_BUFFER_SIZE = 4096;
const size_t I2CP_MAX_MESSAGE_LENGTH = 65535;
const size_t I2CP_MAX_SEND_QUEUE_SIZE = 256;
const size_t I2CP_MAX_SEND_QUEUE_SIZE = 1024*1024; // in bytes, 1M
const size_t I2CP_HEADER_LENGTH_OFFSET = 0;
const size_t I2CP_HEADER_TYPE_OFFSET = I2CP_HEADER_LENGTH_OFFSET + 4;
@ -125,8 +126,6 @@ namespace client
class I2CPServer;
class I2CPSession: public std::enable_shared_from_this<I2CPSession>
{
typedef std::shared_ptr<std::vector<boost::asio::const_buffer> > SendQueue;
public:
#ifdef ANDROID
@ -171,14 +170,12 @@ namespace client
void HandleReceivedPayload (const boost::system::error_code& ecode, std::size_t bytes_transferred);
void HandleMessage ();
void Terminate ();
void SendBuffer (uint8_t * buf, size_t len);
void HandleI2CPMessageSent (const boost::system::error_code& ecode, std::size_t bytes_transferred);
void HandleI2CPMessageSentQueue (const boost::system::error_code& ecode, std::size_t bytes_transferred, SendQueue queue);
std::string ExtractString (const uint8_t * buf, size_t len);
size_t PutString (uint8_t * buf, size_t len, const std::string& str);
void ExtractMapping (const uint8_t * buf, size_t len, std::map<std::string, std::string>& mapping);
void SendSessionStatusMessage (uint8_t status);
void SendHostReplyMessage (uint32_t requestID, std::shared_ptr<const i2p::data::IdentityEx> identity);
@ -197,7 +194,7 @@ namespace client
// to client
bool m_IsSending;
uint8_t m_SendBuffer[I2CP_MAX_MESSAGE_LENGTH];
SendQueue m_SendQueue;
i2p::stream::SendBufferQueue m_SendQueue;
};
typedef void (I2CPSession::*I2CPMessageHandler)(const uint8_t * buf, size_t len);