|
|
@ -1,5 +1,5 @@ |
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2013-2020, The PurpleI2P Project |
|
|
|
* Copyright (c) 2013-2021, The PurpleI2P Project |
|
|
|
* |
|
|
|
* |
|
|
|
* This file is part of Purple i2pd project and licensed under BSD3 |
|
|
|
* This file is part of Purple i2pd project and licensed under BSD3 |
|
|
|
* |
|
|
|
* |
|
|
@ -1115,19 +1115,9 @@ namespace client |
|
|
|
if (ep) |
|
|
|
if (ep) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// udp forward enabled
|
|
|
|
// udp forward enabled
|
|
|
|
size_t bsz = base64.size(); |
|
|
|
const char lf = '\n'; |
|
|
|
size_t sz = bsz + 1 + len; |
|
|
|
// send to remote endpoint, { destination, linefeed, payload }
|
|
|
|
// build datagram body
|
|
|
|
m_Owner.SendTo({ {(const uint8_t *)base64.c_str(), base64.size()}, {(const uint8_t *)&lf, 1}, {buf, len} }, *ep); |
|
|
|
uint8_t * data = new uint8_t[sz]; |
|
|
|
|
|
|
|
// Destination
|
|
|
|
|
|
|
|
memcpy(data, base64.c_str(), bsz); |
|
|
|
|
|
|
|
// linefeed
|
|
|
|
|
|
|
|
data[bsz] = '\n'; |
|
|
|
|
|
|
|
// Payload
|
|
|
|
|
|
|
|
memcpy(data+bsz+1, buf, len); |
|
|
|
|
|
|
|
// send to remote endpoint
|
|
|
|
|
|
|
|
m_Owner.SendTo(data, sz, ep); |
|
|
|
|
|
|
|
delete [] data; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1156,7 +1146,7 @@ namespace client |
|
|
|
auto ep = session->UDPEndpoint; |
|
|
|
auto ep = session->UDPEndpoint; |
|
|
|
if (ep) |
|
|
|
if (ep) |
|
|
|
// udp forward enabled
|
|
|
|
// udp forward enabled
|
|
|
|
m_Owner.SendTo(buf, len, ep); |
|
|
|
m_Owner.SendTo({ {buf, len} }, *ep); |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
#ifdef _MSC_VER |
|
|
|
#ifdef _MSC_VER |
|
|
@ -1453,14 +1443,11 @@ namespace client |
|
|
|
return list; |
|
|
|
return list; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SAMBridge::SendTo(const uint8_t * buf, size_t len, std::shared_ptr<boost::asio::ip::udp::endpoint> remote) |
|
|
|
void SAMBridge::SendTo (const std::vector<boost::asio::const_buffer>& bufs, const boost::asio::ip::udp::endpoint& ep) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if(remote) |
|
|
|
m_DatagramSocket.send_to (bufs, ep); |
|
|
|
{ |
|
|
|
} |
|
|
|
m_DatagramSocket.send_to(boost::asio::buffer(buf, len), *remote); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SAMBridge::ReceiveDatagram () |
|
|
|
void SAMBridge::ReceiveDatagram () |
|
|
|
{ |
|
|
|
{ |
|
|
|
m_DatagramSocket.async_receive_from ( |
|
|
|
m_DatagramSocket.async_receive_from ( |
|
|
|