From 1d7d7cf9a02e1c889b912fb12cdd92af237f34af Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Mon, 22 Aug 2016 17:19:22 -0400 Subject: [PATCH] more changes --- ClientContext.cpp | 3 --- I2PTunnel.cpp | 12 ++++++------ I2PTunnel.h | 3 +-- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/ClientContext.cpp b/ClientContext.cpp index 13c8690a..3b814260 100644 --- a/ClientContext.cpp +++ b/ClientContext.cpp @@ -406,9 +406,6 @@ namespace client // udp client // TODO: ip6 and hostnames boost::asio::ip::udp::endpoint end(boost::asio::ip::address::from_string(address), port); - if(destinationPort == 0) { - destinationPort = port; - } if (!localDestination) { localDestination = m_SharedLocalDestination; } diff --git a/I2PTunnel.cpp b/I2PTunnel.cpp index 7172b23b..6cbb3668 100644 --- a/I2PTunnel.cpp +++ b/I2PTunnel.cpp @@ -534,6 +534,7 @@ namespace client for ( UDPSession * s : m_Sessions ) { if ( s->Identity == ih) { /** found existing */ + LogPrint(eLogDebug, "UDPServer: found session ", s->IPSocket.local_endpoint()); return s; } } @@ -558,20 +559,19 @@ namespace client void UDPSession::Receive() { - LogPrint(eLogDebug, "UDPSesssion: Recveive"); + LogPrint(eLogDebug, "UDPSession: Receive"); IPSocket.async_receive_from(boost::asio::buffer(m_Buffer, I2P_UDP_MAX_MTU), FromEndpoint, std::bind(&UDPSession::HandleReceived, this, std::placeholders::_1, std::placeholders::_2)); } void UDPSession::HandleReceived(const boost::system::error_code & ecode, std::size_t len) { - LogPrint(eLogDebug, "UDPSesssion: HandleRecveived"); if(!ecode) { LogPrint(eLogDebug, "UDPSession: forward ", len, "B from ", FromEndpoint); LastActivity = i2p::util::GetMillisecondsSinceEpoch(); uint8_t * data = new uint8_t[len]; memcpy(data, m_Buffer, len); m_Service.post([&,len, data] () { - m_Destination->SendDatagramTo(data, len, Identity, 0, 0); + m_Destination->SendDatagramTo(data, len, Identity, LocalPort, RemotePort); delete [] data; }); @@ -590,14 +590,14 @@ namespace client m_LocalDest = localDestination; m_LocalDest->Start(); 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); + dgram->SetReceiver(std::bind(&I2PUDPServerTunnel::HandleRecvFromI2P, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5), LocalPort); } I2PUDPServerTunnel::~I2PUDPServerTunnel() { auto dgram = m_LocalDest->GetDatagramDestination(); if (dgram) { - dgram->ResetReceiver(0); + dgram->ResetReceiver(LocalPort); } LogPrint(eLogInfo, "UDPServer: done"); } @@ -658,7 +658,7 @@ namespace client // address match if(m_Session) { // tell session - LogPrint(eLogDebug, "UDP Client: got ", len, "B from ", from.GetIdentHash().ToBase32(), " via ", m_Session->SendEndpoint); + LogPrint(eLogDebug, "UDP Client: got ", len, "B from ", from.GetIdentHash().ToBase32()); m_Session->IPSocket.send_to(boost::asio::buffer(buf, len), m_Session->FromEndpoint); } else { LogPrint(eLogWarning, "UDP Client: no session"); diff --git a/I2PTunnel.h b/I2PTunnel.h index dfd364f0..63341679 100644 --- a/I2PTunnel.h +++ b/I2PTunnel.h @@ -136,7 +136,7 @@ namespace client const uint64_t I2P_UDP_SESSION_TIMEOUT = 1000 * 60 * 2; /** max size for i2p udp */ - const size_t I2P_UDP_MAX_MTU = 4000; + const size_t I2P_UDP_MAX_MTU = i2p::datagram::MAX_DATAGRAM_SIZE; struct UDPSession { @@ -152,7 +152,6 @@ namespace client uint16_t RemotePort; uint8_t m_Buffer[I2P_UDP_MAX_MTU]; - uint8_t * m_Forward; UDPSession(boost::asio::ip::udp::endpoint localEndpoint, const std::shared_ptr & localDestination, boost::asio::ip::udp::endpoint remote, const i2p::data::IdentHash ident, uint16_t ourPort, uint16_t theirPort);