Browse Source

send recived data after address from BOB inbound connection

pull/113/head
orignal 10 years ago
parent
commit
76478ceaa2
  1. 8
      BOB.cpp
  2. 2
      BOB.h
  3. 7
      I2PTunnel.cpp
  4. 2
      I2PTunnel.h

8
BOB.cpp

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

2
BOB.h

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

7
I2PTunnel.cpp

@ -27,9 +27,12 @@ namespace client
delete m_Socket; 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 (); StreamReceive ();
Receive (); Receive ();
} }

2
I2PTunnel.h

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

Loading…
Cancel
Save