diff --git a/BOB.cpp b/BOB.cpp index dae601e5..84928125 100644 --- a/BOB.cpp +++ b/BOB.cpp @@ -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(this, socket, leaseSet); AddConnection (connection); - connection->I2PConnect (); - // TODO: send remaining buffer + connection->I2PConnect (m_ReceivedData, m_ReceivedDataLen); } BOBCommandSession::BOBCommandSession (BOBCommandChannel& owner): diff --git a/BOB.h b/BOB.h index 34901f53..771c4e4c 100644 --- a/BOB.h +++ b/BOB.h @@ -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; diff --git a/I2PTunnel.cpp b/I2PTunnel.cpp index e24ad7c6..e3790c50 100644 --- a/I2PTunnel.cpp +++ b/I2PTunnel.cpp @@ -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 (); } diff --git a/I2PTunnel.h b/I2PTunnel.h index 86eab4a2..990bd867 100644 --- a/I2PTunnel.h +++ b/I2PTunnel.h @@ -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: