mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-28 11:47:48 +02:00
SSU added
This commit is contained in:
parent
d7d3fcef94
commit
3cf3e69aef
5 changed files with 102 additions and 3 deletions
44
SSU.cpp
Normal file
44
SSU.cpp
Normal file
|
@ -0,0 +1,44 @@
|
|||
#include <boost/bind.hpp>
|
||||
#include "Log.h"
|
||||
#include "hmac.h"
|
||||
#include "SSU.h"
|
||||
|
||||
namespace i2p
|
||||
{
|
||||
namespace ssu
|
||||
{
|
||||
SSUServer::SSUServer (boost::asio::io_service& service, int port):
|
||||
m_Socket (service, boost::asio::ip::udp::v4 (), port)
|
||||
{
|
||||
}
|
||||
|
||||
void SSUServer::Start ()
|
||||
{
|
||||
Receive ();
|
||||
}
|
||||
|
||||
void SSUServer::Stop ()
|
||||
{
|
||||
m_Socket.close ();
|
||||
}
|
||||
|
||||
void SSUServer::Receive ()
|
||||
{
|
||||
m_Socket.async_receive_from (boost::asio::buffer (m_ReceiveBuffer, SSU_MTU), m_SenderEndpoint,
|
||||
boost::bind (&SSUServer::HandleReceivedFrom, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
|
||||
}
|
||||
|
||||
void SSUServer::HandleReceivedFrom (const boost::system::error_code& ecode, std::size_t bytes_transferred)
|
||||
{
|
||||
if (!ecode)
|
||||
{
|
||||
LogPrint ("SSU received ", bytes_transferred, " bytes");
|
||||
// Handle
|
||||
Receive ();
|
||||
}
|
||||
else
|
||||
LogPrint ("SSU receive error: ", ecode.message ());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue