mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 08:14:15 +00:00
replaced boost::bind to std::bind
This commit is contained in:
parent
4bd8b44ab2
commit
0262a8b057
@ -38,7 +38,7 @@ namespace datagram
|
|||||||
|
|
||||||
auto service = m_Owner.GetService ();
|
auto service = m_Owner.GetService ();
|
||||||
if (service)
|
if (service)
|
||||||
service->post (boost::bind (&DatagramDestination::SendMsg, this,
|
service->post (std::bind (&DatagramDestination::SendMsg, this,
|
||||||
CreateDataMessage (buf, len + headerLen), remote));
|
CreateDataMessage (buf, len + headerLen), remote));
|
||||||
else
|
else
|
||||||
LogPrint (eLogWarning, "Failed to send datagram. Destination is not running");
|
LogPrint (eLogWarning, "Failed to send datagram. Destination is not running");
|
||||||
|
@ -190,12 +190,12 @@ namespace client
|
|||||||
|
|
||||||
void ClientDestination::ProcessGarlicMessage (I2NPMessage * msg)
|
void ClientDestination::ProcessGarlicMessage (I2NPMessage * msg)
|
||||||
{
|
{
|
||||||
m_Service->post (boost::bind (&ClientDestination::HandleGarlicMessage, this, msg));
|
m_Service->post (std::bind (&ClientDestination::HandleGarlicMessage, this, msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientDestination::ProcessDeliveryStatusMessage (I2NPMessage * msg)
|
void ClientDestination::ProcessDeliveryStatusMessage (I2NPMessage * msg)
|
||||||
{
|
{
|
||||||
m_Service->post (boost::bind (&ClientDestination::HandleDeliveryStatusMessage, this, msg));
|
m_Service->post (std::bind (&ClientDestination::HandleDeliveryStatusMessage, this, msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientDestination::HandleI2NPMessage (const uint8_t * buf, size_t len, i2p::tunnel::InboundTunnel * from)
|
void ClientDestination::HandleI2NPMessage (const uint8_t * buf, size_t len, i2p::tunnel::InboundTunnel * from)
|
||||||
|
51
SAM.cpp
51
SAM.cpp
@ -3,7 +3,6 @@
|
|||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#endif
|
#endif
|
||||||
#include <boost/bind.hpp>
|
|
||||||
#include "base64.h"
|
#include "base64.h"
|
||||||
#include "Identity.h"
|
#include "Identity.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
@ -72,8 +71,8 @@ namespace client
|
|||||||
void SAMSocket::ReceiveHandshake ()
|
void SAMSocket::ReceiveHandshake ()
|
||||||
{
|
{
|
||||||
m_Socket.async_read_some (boost::asio::buffer(m_Buffer, SAM_SOCKET_BUFFER_SIZE),
|
m_Socket.async_read_some (boost::asio::buffer(m_Buffer, SAM_SOCKET_BUFFER_SIZE),
|
||||||
boost::bind(&SAMSocket::HandleHandshakeReceived, shared_from_this (),
|
std::bind(&SAMSocket::HandleHandshakeReceived, shared_from_this (),
|
||||||
boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
|
std::placeholders::_1, std::placeholders::_2));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SAMSocket::HandleHandshakeReceived (const boost::system::error_code& ecode, std::size_t bytes_transferred)
|
void SAMSocket::HandleHandshakeReceived (const boost::system::error_code& ecode, std::size_t bytes_transferred)
|
||||||
@ -92,8 +91,8 @@ namespace client
|
|||||||
{
|
{
|
||||||
// TODO: check version
|
// TODO: check version
|
||||||
boost::asio::async_write (m_Socket, boost::asio::buffer (SAM_HANDSHAKE_REPLY, strlen (SAM_HANDSHAKE_REPLY)), boost::asio::transfer_all (),
|
boost::asio::async_write (m_Socket, boost::asio::buffer (SAM_HANDSHAKE_REPLY, strlen (SAM_HANDSHAKE_REPLY)), boost::asio::transfer_all (),
|
||||||
boost::bind(&SAMSocket::HandleHandshakeReplySent, shared_from_this (),
|
std::bind(&SAMSocket::HandleHandshakeReplySent, shared_from_this (),
|
||||||
boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
|
std::placeholders::_1, std::placeholders::_2));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -114,8 +113,8 @@ namespace client
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_Socket.async_read_some (boost::asio::buffer(m_Buffer, SAM_SOCKET_BUFFER_SIZE),
|
m_Socket.async_read_some (boost::asio::buffer(m_Buffer, SAM_SOCKET_BUFFER_SIZE),
|
||||||
boost::bind(&SAMSocket::HandleMessage, shared_from_this (),
|
std::bind(&SAMSocket::HandleMessage, shared_from_this (),
|
||||||
boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
|
std::placeholders::_1, std::placeholders::_2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,8 +122,8 @@ namespace client
|
|||||||
{
|
{
|
||||||
if (!m_IsSilent || m_SocketType == eSAMSocketTypeAcceptor)
|
if (!m_IsSilent || m_SocketType == eSAMSocketTypeAcceptor)
|
||||||
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 (),
|
||||||
boost::bind(&SAMSocket::HandleMessageReplySent, shared_from_this (),
|
std::bind(&SAMSocket::HandleMessageReplySent, shared_from_this (),
|
||||||
boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred, close));
|
std::placeholders::_1, std::placeholders::_2, close));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (close)
|
if (close)
|
||||||
@ -237,8 +236,8 @@ namespace client
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_Timer.expires_from_now (boost::posix_time::seconds(SAM_SESSION_READINESS_CHECK_INTERVAL));
|
m_Timer.expires_from_now (boost::posix_time::seconds(SAM_SESSION_READINESS_CHECK_INTERVAL));
|
||||||
m_Timer.async_wait (boost::bind (&SAMSocket::HandleSessionReadinessCheckTimer,
|
m_Timer.async_wait (std::bind (&SAMSocket::HandleSessionReadinessCheckTimer,
|
||||||
shared_from_this (), boost::asio::placeholders::error));
|
shared_from_this (), std::placeholders::_1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -254,8 +253,8 @@ namespace client
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_Timer.expires_from_now (boost::posix_time::seconds(SAM_SESSION_READINESS_CHECK_INTERVAL));
|
m_Timer.expires_from_now (boost::posix_time::seconds(SAM_SESSION_READINESS_CHECK_INTERVAL));
|
||||||
m_Timer.async_wait (boost::bind (&SAMSocket::HandleSessionReadinessCheckTimer,
|
m_Timer.async_wait (std::bind (&SAMSocket::HandleSessionReadinessCheckTimer,
|
||||||
shared_from_this (), boost::asio::placeholders::error));
|
shared_from_this (), std::placeholders::_1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -299,8 +298,8 @@ namespace client
|
|||||||
{
|
{
|
||||||
i2p::data::netdb.RequestDestination (dest.GetIdentHash (), true, m_Session->localDestination->GetTunnelPool ());
|
i2p::data::netdb.RequestDestination (dest.GetIdentHash (), true, m_Session->localDestination->GetTunnelPool ());
|
||||||
m_Timer.expires_from_now (boost::posix_time::seconds(SAM_CONNECT_TIMEOUT));
|
m_Timer.expires_from_now (boost::posix_time::seconds(SAM_CONNECT_TIMEOUT));
|
||||||
m_Timer.async_wait (boost::bind (&SAMSocket::HandleStreamDestinationRequestTimer,
|
m_Timer.async_wait (std::bind (&SAMSocket::HandleStreamDestinationRequestTimer,
|
||||||
shared_from_this (), boost::asio::placeholders::error, dest.GetIdentHash ()));
|
shared_from_this (), std::placeholders::_1, dest.GetIdentHash ()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -422,8 +421,8 @@ namespace client
|
|||||||
{
|
{
|
||||||
i2p::data::netdb.RequestDestination (ident, true, m_Session->localDestination->GetTunnelPool ());
|
i2p::data::netdb.RequestDestination (ident, true, m_Session->localDestination->GetTunnelPool ());
|
||||||
m_Timer.expires_from_now (boost::posix_time::seconds(SAM_NAMING_LOOKUP_TIMEOUT));
|
m_Timer.expires_from_now (boost::posix_time::seconds(SAM_NAMING_LOOKUP_TIMEOUT));
|
||||||
m_Timer.async_wait (boost::bind (&SAMSocket::HandleNamingLookupDestinationRequestTimer,
|
m_Timer.async_wait (std::bind (&SAMSocket::HandleNamingLookupDestinationRequestTimer,
|
||||||
shared_from_this (), boost::asio::placeholders::error, ident));
|
shared_from_this (), std::placeholders::_1, ident));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -475,8 +474,8 @@ namespace client
|
|||||||
void SAMSocket::Receive ()
|
void SAMSocket::Receive ()
|
||||||
{
|
{
|
||||||
m_Socket.async_read_some (boost::asio::buffer(m_Buffer, SAM_SOCKET_BUFFER_SIZE),
|
m_Socket.async_read_some (boost::asio::buffer(m_Buffer, SAM_SOCKET_BUFFER_SIZE),
|
||||||
boost::bind((m_SocketType == eSAMSocketTypeSession) ? &SAMSocket::HandleMessage : &SAMSocket::HandleReceived,
|
std::bind((m_SocketType == eSAMSocketTypeSession) ? &SAMSocket::HandleMessage : &SAMSocket::HandleReceived,
|
||||||
shared_from_this (), boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
|
shared_from_this (), std::placeholders::_1, std::placeholders::_2));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SAMSocket::HandleReceived (const boost::system::error_code& ecode, std::size_t bytes_transferred)
|
void SAMSocket::HandleReceived (const boost::system::error_code& ecode, std::size_t bytes_transferred)
|
||||||
@ -499,8 +498,8 @@ namespace client
|
|||||||
{
|
{
|
||||||
if (m_Stream)
|
if (m_Stream)
|
||||||
m_Stream->AsyncReceive (boost::asio::buffer (m_StreamBuffer, SAM_SOCKET_BUFFER_SIZE),
|
m_Stream->AsyncReceive (boost::asio::buffer (m_StreamBuffer, SAM_SOCKET_BUFFER_SIZE),
|
||||||
boost::bind (&SAMSocket::HandleI2PReceive, shared_from_this (),
|
std::bind (&SAMSocket::HandleI2PReceive, shared_from_this (),
|
||||||
boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred),
|
std::placeholders::_1, std::placeholders::_2),
|
||||||
SAM_SOCKET_CONNECTION_MAX_IDLE);
|
SAM_SOCKET_CONNECTION_MAX_IDLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -515,7 +514,7 @@ namespace client
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
boost::asio::async_write (m_Socket, boost::asio::buffer (m_StreamBuffer, bytes_transferred),
|
boost::asio::async_write (m_Socket, boost::asio::buffer (m_StreamBuffer, bytes_transferred),
|
||||||
boost::bind (&SAMSocket::HandleWriteI2PData, shared_from_this (), boost::asio::placeholders::error));
|
std::bind (&SAMSocket::HandleWriteI2PData, shared_from_this (), std::placeholders::_1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -568,7 +567,7 @@ namespace client
|
|||||||
{
|
{
|
||||||
memcpy (m_StreamBuffer + l2, buf, len);
|
memcpy (m_StreamBuffer + l2, buf, len);
|
||||||
boost::asio::async_write (m_Socket, boost::asio::buffer (m_StreamBuffer, len + l2),
|
boost::asio::async_write (m_Socket, boost::asio::buffer (m_StreamBuffer, len + l2),
|
||||||
boost::bind (&SAMSocket::HandleWriteI2PData, shared_from_this (), boost::asio::placeholders::error));
|
std::bind (&SAMSocket::HandleWriteI2PData, shared_from_this (), std::placeholders::_1));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
LogPrint (eLogWarning, "Datagram size ", len," exceeds buffer");
|
LogPrint (eLogWarning, "Datagram size ", len," exceeds buffer");
|
||||||
@ -624,8 +623,8 @@ namespace client
|
|||||||
void SAMBridge::Accept ()
|
void SAMBridge::Accept ()
|
||||||
{
|
{
|
||||||
auto newSocket = std::make_shared<SAMSocket> (*this);
|
auto newSocket = std::make_shared<SAMSocket> (*this);
|
||||||
m_Acceptor.async_accept (newSocket->GetSocket (), boost::bind (&SAMBridge::HandleAccept, this,
|
m_Acceptor.async_accept (newSocket->GetSocket (), std::bind (&SAMBridge::HandleAccept, this,
|
||||||
boost::asio::placeholders::error, newSocket));
|
std::placeholders::_1, newSocket));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SAMBridge::HandleAccept(const boost::system::error_code& ecode, std::shared_ptr<SAMSocket> socket)
|
void SAMBridge::HandleAccept(const boost::system::error_code& ecode, std::shared_ptr<SAMSocket> socket)
|
||||||
@ -697,7 +696,7 @@ namespace client
|
|||||||
m_DatagramSocket.async_receive_from (
|
m_DatagramSocket.async_receive_from (
|
||||||
boost::asio::buffer (m_DatagramReceiveBuffer, i2p::datagram::MAX_DATAGRAM_SIZE),
|
boost::asio::buffer (m_DatagramReceiveBuffer, i2p::datagram::MAX_DATAGRAM_SIZE),
|
||||||
m_SenderEndpoint,
|
m_SenderEndpoint,
|
||||||
boost::bind (&SAMBridge::HandleReceivedDatagram, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
|
std::bind (&SAMBridge::HandleReceivedDatagram, this, std::placeholders::_1, std::placeholders::_2));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SAMBridge::HandleReceivedDatagram (const boost::system::error_code& ecode, std::size_t bytes_transferred)
|
void SAMBridge::HandleReceivedDatagram (const boost::system::error_code& ecode, std::size_t bytes_transferred)
|
||||||
|
@ -102,8 +102,8 @@ namespace stream
|
|||||||
{
|
{
|
||||||
m_IsAckSendScheduled = true;
|
m_IsAckSendScheduled = true;
|
||||||
m_AckSendTimer.expires_from_now (boost::posix_time::milliseconds(ACK_SEND_TIMEOUT));
|
m_AckSendTimer.expires_from_now (boost::posix_time::milliseconds(ACK_SEND_TIMEOUT));
|
||||||
m_AckSendTimer.async_wait (boost::bind (&Stream::HandleAckSendTimer,
|
m_AckSendTimer.async_wait (std::bind (&Stream::HandleAckSendTimer,
|
||||||
shared_from_this (), boost::asio::placeholders::error));
|
shared_from_this (), std::placeholders::_1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (isSyn)
|
else if (isSyn)
|
||||||
@ -309,7 +309,7 @@ namespace stream
|
|||||||
size += sentLen; // payload
|
size += sentLen; // payload
|
||||||
}
|
}
|
||||||
p->len = size;
|
p->len = size;
|
||||||
m_Service.post (boost::bind (&Stream::SendPacket, this, p));
|
m_Service.post (std::bind (&Stream::SendPacket, this, p));
|
||||||
}
|
}
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
@ -460,8 +460,8 @@ namespace stream
|
|||||||
{
|
{
|
||||||
m_ResendTimer.cancel ();
|
m_ResendTimer.cancel ();
|
||||||
m_ResendTimer.expires_from_now (boost::posix_time::seconds(RESEND_TIMEOUT));
|
m_ResendTimer.expires_from_now (boost::posix_time::seconds(RESEND_TIMEOUT));
|
||||||
m_ResendTimer.async_wait (boost::bind (&Stream::HandleResendTimer,
|
m_ResendTimer.async_wait (std::bind (&Stream::HandleResendTimer,
|
||||||
shared_from_this (), boost::asio::placeholders::error));
|
shared_from_this (), std::placeholders::_1));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Stream::HandleResendTimer (const boost::system::error_code& ecode)
|
void Stream::HandleResendTimer (const boost::system::error_code& ecode)
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
#include <boost/bind.hpp>
|
|
||||||
#include "I2PEndian.h"
|
#include "I2PEndian.h"
|
||||||
#include "Identity.h"
|
#include "Identity.h"
|
||||||
#include "LeaseSet.h"
|
#include "LeaseSet.h"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user