1
0
mirror of https://github.com/PurpleI2P/i2pd.git synced 2025-01-13 19:37:51 +00:00

send recived data after address from BOB inbound connection

This commit is contained in:
orignal 2014-12-03 20:37:20 -05:00
parent 9328bd1caf
commit 76478ceaa2
4 changed files with 13 additions and 6 deletions

View File

@ -12,7 +12,7 @@ namespace client
BOBI2PInboundTunnel::BOBI2PInboundTunnel (boost::asio::io_service& service, int port, ClientDestination * localDestination):
I2PTunnel (service, localDestination),
m_Acceptor (service, boost::asio::ip::tcp::endpoint (boost::asio::ip::tcp::v4(), port)),
m_Timer (service)
m_Timer (service), m_ReceivedData (nullptr), m_ReceivedDataLen (0)
{
}
@ -72,6 +72,9 @@ namespace client
if (eol)
{
*eol = 0;
m_ReceivedData = (uint8_t *)eol + 1;
m_ReceivedDataLen = bytes_transferred - (eol - m_ReceiveBuffer + 1);
i2p::data::IdentHash ident;
i2p::data::IdentityEx dest;
dest.FromBase64 (m_ReceiveBuffer); // TODO: might be .i2p address
@ -116,8 +119,7 @@ namespace client
LogPrint ("New BOB inbound connection");
auto connection = std::make_shared<I2PTunnelConnection>(this, socket, leaseSet);
AddConnection (connection);
connection->I2PConnect ();
// TODO: send remaining buffer
connection->I2PConnect (m_ReceivedData, m_ReceivedDataLen);
}
BOBCommandSession::BOBCommandSession (BOBCommandChannel& owner):

2
BOB.h
View File

@ -59,6 +59,8 @@ namespace client
boost::asio::ip::tcp::acceptor m_Acceptor;
boost::asio::deadline_timer m_Timer;
char m_ReceiveBuffer[BOB_COMMAND_BUFFER_SIZE + 1]; // for destination base64 address
uint8_t * m_ReceivedData;
size_t m_ReceivedDataLen;
};
class BOBCommandChannel;

View File

@ -27,9 +27,12 @@ namespace client
delete m_Socket;
}
void I2PTunnelConnection::I2PConnect ()
void I2PTunnelConnection::I2PConnect (const uint8_t * msg, size_t len)
{
m_Stream->Send (m_Buffer, 0); // connect
if (msg)
m_Stream->Send (msg, len); // connect and send
else
m_Stream->Send (m_Buffer, 0); // connect
StreamReceive ();
Receive ();
}

View File

@ -29,7 +29,7 @@ namespace client
const boost::asio::ip::tcp::endpoint& target);
~I2PTunnelConnection ();
void I2PConnect ();
void I2PConnect (const uint8_t * msg = nullptr, size_t len = 0);
void Connect ();
private: