mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 21:37:17 +01:00
use stream buffer for sending identity
This commit is contained in:
parent
feffbc9330
commit
ac438fbd7d
13
SAM.cpp
13
SAM.cpp
|
@ -148,7 +148,7 @@ namespace client
|
||||||
|
|
||||||
void SAMSocket::SendMessageReply (const char * msg, size_t len, bool close)
|
void SAMSocket::SendMessageReply (const char * msg, size_t len, bool close)
|
||||||
{
|
{
|
||||||
if (!m_IsSilent || m_SocketType == eSAMSocketTypeAcceptor)
|
if (!m_IsSilent)
|
||||||
boost::asio::async_write (m_Socket, boost::asio::buffer (msg, len), boost::asio::transfer_all (),
|
boost::asio::async_write (m_Socket, boost::asio::buffer (msg, len), boost::asio::transfer_all (),
|
||||||
std::bind(&SAMSocket::HandleMessageReplySent, shared_from_this (),
|
std::bind(&SAMSocket::HandleMessageReplySent, shared_from_this (),
|
||||||
std::placeholders::_1, std::placeholders::_2, close));
|
std::placeholders::_1, std::placeholders::_2, close));
|
||||||
|
@ -320,7 +320,7 @@ namespace client
|
||||||
i2p::data::IdentityEx dest;
|
i2p::data::IdentityEx dest;
|
||||||
dest.FromBase64 (destination);
|
dest.FromBase64 (destination);
|
||||||
context.GetAddressBook ().InsertAddress (dest);
|
context.GetAddressBook ().InsertAddress (dest);
|
||||||
auto leaseSet = i2p::data::netdb.FindLeaseSet (dest.GetIdentHash ());
|
auto leaseSet = m_Session->localDestination->FindLeaseSet (dest.GetIdentHash ());
|
||||||
if (leaseSet)
|
if (leaseSet)
|
||||||
Connect (leaseSet);
|
Connect (leaseSet);
|
||||||
else
|
else
|
||||||
|
@ -347,7 +347,7 @@ namespace client
|
||||||
void SAMSocket::HandleConnectLeaseSetRequestComplete (bool success, i2p::data::IdentHash ident)
|
void SAMSocket::HandleConnectLeaseSetRequestComplete (bool success, i2p::data::IdentHash ident)
|
||||||
{
|
{
|
||||||
std::shared_ptr<const i2p::data::LeaseSet> leaseSet;
|
std::shared_ptr<const i2p::data::LeaseSet> leaseSet;
|
||||||
if (success) // timeout expired
|
if (success)
|
||||||
leaseSet = m_Session->localDestination->FindLeaseSet (ident);
|
leaseSet = m_Session->localDestination->FindLeaseSet (ident);
|
||||||
if (leaseSet)
|
if (leaseSet)
|
||||||
Connect (leaseSet);
|
Connect (leaseSet);
|
||||||
|
@ -566,10 +566,11 @@ namespace client
|
||||||
// send remote peer address
|
// send remote peer address
|
||||||
uint8_t ident[1024];
|
uint8_t ident[1024];
|
||||||
size_t l = stream->GetRemoteIdentity ().ToBuffer (ident, 1024);
|
size_t l = stream->GetRemoteIdentity ().ToBuffer (ident, 1024);
|
||||||
size_t l1 = i2p::data::ByteStreamToBase64 (ident, l, m_Buffer, SAM_SOCKET_BUFFER_SIZE);
|
size_t l1 = i2p::data::ByteStreamToBase64 (ident, l, (char *)m_StreamBuffer, SAM_SOCKET_BUFFER_SIZE);
|
||||||
m_Buffer[l1] = '\n';
|
m_StreamBuffer[l1] = '\n';
|
||||||
SendMessageReply (m_Buffer, l1 + 1, false);
|
HandleI2PReceive (boost::system::error_code (), l1 +1); // we send identity like it has been received from stream
|
||||||
}
|
}
|
||||||
|
else
|
||||||
I2PReceive ();
|
I2PReceive ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue