mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 16:34:13 +00:00
changes
This commit is contained in:
parent
72974c85c8
commit
7b5e18d94b
@ -466,7 +466,7 @@ namespace client
|
|||||||
std::make_pair(
|
std::make_pair(
|
||||||
localDestination->GetIdentHash(), port),
|
localDestination->GetIdentHash(), port),
|
||||||
std::unique_ptr<I2PUDPServerTunnel>(serverTunnel))).second) {
|
std::unique_ptr<I2PUDPServerTunnel>(serverTunnel))).second) {
|
||||||
LogPrint(eLogInfo, "Cleints: I2P Server Forward created for UDP Endpoint ", host, ":", port, " via ",localDestination->GetIdentHash().ToBase32());
|
LogPrint(eLogInfo, "Clients: I2P Server Forward created for UDP Endpoint ", host, ":", port, " via ",localDestination->GetIdentHash().ToBase32());
|
||||||
} else {
|
} else {
|
||||||
LogPrint(eLogError, "Clients: I2P Server Forward for destination/port ", m_AddressBook.ToAddress(localDestination->GetIdentHash()), "/", port, "already exists");
|
LogPrint(eLogError, "Clients: I2P Server Forward for destination/port ", m_AddressBook.ToAddress(localDestination->GetIdentHash()), "/", port, "already exists");
|
||||||
}
|
}
|
||||||
|
@ -677,8 +677,6 @@ namespace client
|
|||||||
|
|
||||||
ClientDestination::~ClientDestination ()
|
ClientDestination::~ClientDestination ()
|
||||||
{
|
{
|
||||||
if (m_DatagramDestination)
|
|
||||||
delete m_DatagramDestination;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ClientDestination::Start ()
|
bool ClientDestination::Start ()
|
||||||
@ -703,13 +701,8 @@ namespace client
|
|||||||
m_StreamingDestination = nullptr;
|
m_StreamingDestination = nullptr;
|
||||||
for (auto& it: m_StreamingDestinationsByPorts)
|
for (auto& it: m_StreamingDestinationsByPorts)
|
||||||
it.second->Stop ();
|
it.second->Stop ();
|
||||||
if (m_DatagramDestination)
|
m_DatagramDestination = nullptr;
|
||||||
{
|
return true;
|
||||||
auto d = m_DatagramDestination;
|
|
||||||
m_DatagramDestination = nullptr;
|
|
||||||
delete d;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
@ -819,10 +812,10 @@ namespace client
|
|||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
i2p::datagram::DatagramDestination * ClientDestination::CreateDatagramDestination ()
|
std::shared_ptr<i2p::datagram::DatagramDestination> ClientDestination::CreateDatagramDestination ()
|
||||||
{
|
{
|
||||||
if (!m_DatagramDestination)
|
if (m_DatagramDestination == nullptr)
|
||||||
m_DatagramDestination = new i2p::datagram::DatagramDestination (GetSharedFromThis ());
|
m_DatagramDestination = std::make_shared<i2p::datagram::DatagramDestination> (GetSharedFromThis ());
|
||||||
return m_DatagramDestination;
|
return m_DatagramDestination;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,8 +164,8 @@ namespace client
|
|||||||
bool IsAcceptingStreams () const;
|
bool IsAcceptingStreams () const;
|
||||||
|
|
||||||
// datagram
|
// datagram
|
||||||
i2p::datagram::DatagramDestination * GetDatagramDestination () const { return m_DatagramDestination; };
|
std::shared_ptr<i2p::datagram::DatagramDestination> GetDatagramDestination () const { return m_DatagramDestination; };
|
||||||
i2p::datagram::DatagramDestination * CreateDatagramDestination ();
|
std::shared_ptr<i2p::datagram::DatagramDestination> CreateDatagramDestination ();
|
||||||
|
|
||||||
// implements LocalDestination
|
// implements LocalDestination
|
||||||
const uint8_t * GetEncryptionPrivateKey () const { return m_EncryptionPrivateKey; };
|
const uint8_t * GetEncryptionPrivateKey () const { return m_EncryptionPrivateKey; };
|
||||||
@ -190,7 +190,7 @@ namespace client
|
|||||||
|
|
||||||
std::shared_ptr<i2p::stream::StreamingDestination> m_StreamingDestination; // default
|
std::shared_ptr<i2p::stream::StreamingDestination> m_StreamingDestination; // default
|
||||||
std::map<uint16_t, std::shared_ptr<i2p::stream::StreamingDestination> > m_StreamingDestinationsByPorts;
|
std::map<uint16_t, std::shared_ptr<i2p::stream::StreamingDestination> > m_StreamingDestinationsByPorts;
|
||||||
i2p::datagram::DatagramDestination * m_DatagramDestination;
|
std::shared_ptr<i2p::datagram::DatagramDestination> m_DatagramDestination;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -539,14 +539,14 @@ namespace client
|
|||||||
}
|
}
|
||||||
/** create new */
|
/** create new */
|
||||||
boost::asio::ip::udp::endpoint ep(boost::asio::ip::address::from_string("127.0.0.1"), 0);
|
boost::asio::ip::udp::endpoint ep(boost::asio::ip::address::from_string("127.0.0.1"), 0);
|
||||||
m_Sessions.push_back(UDPSession(m_Service, ep, m_Destination, m_Endpoint, ih, localPort, remotePort));
|
m_Sessions.push_back(UDPSession(m_Service, ep, m_LocalDest, m_Endpoint, ih, localPort, remotePort));
|
||||||
auto & s = m_Sessions.back();
|
auto & s = m_Sessions.back();
|
||||||
s.SendEndpoint = s.IPSocket.local_endpoint();
|
s.SendEndpoint = s.IPSocket.local_endpoint();
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
UDPSession::UDPSession(boost::asio::io_service & ios, boost::asio::ip::udp::endpoint localEndpoint, std::shared_ptr<i2p::client::ClientDestination> localDestination, boost::asio::ip::udp::endpoint endpoint, const i2p::data::IdentHash to, uint16_t ourPort, uint16_t theirPort) :
|
UDPSession::UDPSession(boost::asio::io_service & ios, boost::asio::ip::udp::endpoint localEndpoint, std::shared_ptr<i2p::client::ClientDestination> localDestination, boost::asio::ip::udp::endpoint endpoint, const i2p::data::IdentHash to, uint16_t ourPort, uint16_t theirPort) :
|
||||||
Destination(localDestination),
|
m_Destination(localDestination),
|
||||||
IPSocket(ios, localEndpoint),
|
IPSocket(ios, localEndpoint),
|
||||||
Identity(to),
|
Identity(to),
|
||||||
SendEndpoint(endpoint),
|
SendEndpoint(endpoint),
|
||||||
@ -569,17 +569,12 @@ namespace client
|
|||||||
LogPrint(eLogDebug, "UDPSesssion: HandleRecveived");
|
LogPrint(eLogDebug, "UDPSesssion: HandleRecveived");
|
||||||
if(!ecode) {
|
if(!ecode) {
|
||||||
LogPrint(eLogDebug, "UDPSession: forward ", len, "B from ", FromEndpoint);
|
LogPrint(eLogDebug, "UDPSession: forward ", len, "B from ", FromEndpoint);
|
||||||
if (Destination) {
|
auto dgram = m_Destination->GetDatagramDestination();
|
||||||
auto dgram = Destination->CreateDatagramDestination();
|
if(dgram) {
|
||||||
if(dgram) {
|
LastActivity = i2p::util::GetMillisecondsSinceEpoch();
|
||||||
LastActivity = i2p::util::GetMillisecondsSinceEpoch();
|
dgram->SendDatagramTo(m_Buffer, len, Identity, 0, 0);
|
||||||
dgram->SendDatagramTo(m_Buffer, len, Identity, 0, 0);
|
|
||||||
LogPrint(eLogDebug, "UDPSession: forward ", len, "B to ", Identity.ToBase32(), " from ", Destination->GetIdentHash().ToBase32());
|
|
||||||
} else {
|
|
||||||
LogPrint(eLogWarning, "UDPSession: no datagram destination");
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
LogPrint(eLogWarning, "UDPSession: no Local Destination");
|
LogPrint(eLogWarning, "UDPSession: no datagram destination");
|
||||||
}
|
}
|
||||||
Receive();
|
Receive();
|
||||||
} else {
|
} else {
|
||||||
@ -590,20 +585,21 @@ namespace client
|
|||||||
I2PUDPServerTunnel::I2PUDPServerTunnel(const std::string & name, std::shared_ptr<i2p::client::ClientDestination> localDestination, boost::asio::ip::udp::endpoint forwardTo, uint16_t port, boost::asio::io_service & service) :
|
I2PUDPServerTunnel::I2PUDPServerTunnel(const std::string & name, std::shared_ptr<i2p::client::ClientDestination> localDestination, boost::asio::ip::udp::endpoint forwardTo, uint16_t port, boost::asio::io_service & service) :
|
||||||
LocalPort(port),
|
LocalPort(port),
|
||||||
m_Endpoint(forwardTo),
|
m_Endpoint(forwardTo),
|
||||||
m_Service(service),
|
m_Service(service)
|
||||||
m_Destination(localDestination)
|
|
||||||
{
|
{
|
||||||
i2p::datagram::DatagramDestination * dgram = m_Destination->CreateDatagramDestination();
|
m_LocalDest = localDestination;
|
||||||
if(dgram)
|
m_LocalDest->Start();
|
||||||
dgram->SetReceiver(std::bind(&I2PUDPServerTunnel::HandleRecvFromI2P, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5), 0);
|
auto dgram = m_LocalDest->CreateDatagramDestination();
|
||||||
|
dgram->SetReceiver(std::bind(&I2PUDPServerTunnel::HandleRecvFromI2P, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
I2PUDPServerTunnel::~I2PUDPServerTunnel()
|
I2PUDPServerTunnel::~I2PUDPServerTunnel()
|
||||||
{
|
{
|
||||||
i2p::datagram::DatagramDestination * dgram = m_Destination->GetDatagramDestination();
|
auto dgram = m_LocalDest->GetDatagramDestination();
|
||||||
if (dgram) {
|
if (dgram) {
|
||||||
dgram->ResetReceiver(0);
|
dgram->ResetReceiver(0);
|
||||||
}
|
}
|
||||||
|
LogPrint(eLogInfo, "UDPServer: done");
|
||||||
}
|
}
|
||||||
|
|
||||||
I2PUDPClientTunnel::I2PUDPClientTunnel(const std::string & name, const std::string &remoteDest, boost::asio::ip::udp::endpoint localEndpoint, std::shared_ptr<i2p::client::ClientDestination> localDestination, uint16_t remotePort, boost::asio::io_service & service) :
|
I2PUDPClientTunnel::I2PUDPClientTunnel(const std::string & name, const std::string &remoteDest, boost::asio::ip::udp::endpoint localEndpoint, std::shared_ptr<i2p::client::ClientDestination> localDestination, uint16_t remotePort, boost::asio::io_service & service) :
|
||||||
|
@ -140,7 +140,7 @@ namespace client
|
|||||||
|
|
||||||
struct UDPSession
|
struct UDPSession
|
||||||
{
|
{
|
||||||
std::shared_ptr<i2p::client::ClientDestination> Destination;
|
std::shared_ptr<i2p::client::ClientDestination> m_Destination;
|
||||||
boost::asio::ip::udp::socket IPSocket;
|
boost::asio::ip::udp::socket IPSocket;
|
||||||
i2p::data::IdentHash Identity;
|
i2p::data::IdentHash Identity;
|
||||||
boost::asio::ip::udp::endpoint FromEndpoint;
|
boost::asio::ip::udp::endpoint FromEndpoint;
|
||||||
@ -177,7 +177,7 @@ namespace client
|
|||||||
std::mutex m_SessionsMutex;
|
std::mutex m_SessionsMutex;
|
||||||
std::vector<UDPSession> m_Sessions;
|
std::vector<UDPSession> m_Sessions;
|
||||||
boost::asio::io_service & m_Service;
|
boost::asio::io_service & m_Service;
|
||||||
std::shared_ptr<i2p::client::ClientDestination> m_Destination;
|
std::shared_ptr<i2p::client::ClientDestination> m_LocalDest;
|
||||||
uint8_t m_Buffer[I2P_UDP_MAX_MTU];
|
uint8_t m_Buffer[I2P_UDP_MAX_MTU];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user