send tunnel test mesaage only if encrypted

This commit is contained in:
orignal 2024-02-27 08:30:31 -05:00
parent 3215125950
commit 6898d04a1d

View File

@ -399,7 +399,7 @@ namespace tunnel
std::unique_lock<std::mutex> l(m_TestsMutex); std::unique_lock<std::mutex> l(m_TestsMutex);
m_Tests[msgID] = it; m_Tests[msgID] = it;
} }
auto msg = CreateTunnelTestMsg (msgID); auto msg = encrypt ? CreateTunnelTestMsg (msgID) : CreateDeliveryStatusMsg (msgID);
auto outbound = it.first; auto outbound = it.first;
auto s = shared_from_this (); auto s = shared_from_this ();
msg->onDrop = [msgID, outbound, s]() msg->onDrop = [msgID, outbound, s]()
@ -452,10 +452,13 @@ namespace tunnel
buf += 4; buf += 4;
uint64_t timestamp = bufbe64toh (buf); uint64_t timestamp = bufbe64toh (buf);
if (m_LocalDestination) if (!ProcessTunnelTest (msgID, timestamp)) // if non encrypted
m_LocalDestination->ProcessDeliveryStatusMessage (msg); {
else if (m_LocalDestination)
LogPrint (eLogWarning, "Tunnels: Local destination doesn't exist, dropped"); m_LocalDestination->ProcessDeliveryStatusMessage (msg);
else
LogPrint (eLogWarning, "Tunnels: Local destination doesn't exist, dropped");
}
} }
void TunnelPool::ProcessTunnelTest (std::shared_ptr<I2NPMessage> msg) void TunnelPool::ProcessTunnelTest (std::shared_ptr<I2NPMessage> msg)
@ -832,7 +835,7 @@ namespace tunnel
{ {
std::shared_ptr<InboundTunnel> tun = nullptr; std::shared_ptr<InboundTunnel> tun = nullptr;
std::unique_lock<std::mutex> lock(m_InboundTunnelsMutex); std::unique_lock<std::mutex> lock(m_InboundTunnelsMutex);
uint64_t min = 1000000; int min = 1000000;
for (const auto & itr : m_InboundTunnels) { for (const auto & itr : m_InboundTunnels) {
if(!itr->LatencyIsKnown()) continue; if(!itr->LatencyIsKnown()) continue;
auto l = itr->GetMeanLatency(); auto l = itr->GetMeanLatency();
@ -848,7 +851,7 @@ namespace tunnel
{ {
std::shared_ptr<OutboundTunnel> tun = nullptr; std::shared_ptr<OutboundTunnel> tun = nullptr;
std::unique_lock<std::mutex> lock(m_OutboundTunnelsMutex); std::unique_lock<std::mutex> lock(m_OutboundTunnelsMutex);
uint64_t min = 1000000; int min = 1000000;
for (const auto & itr : m_OutboundTunnels) { for (const auto & itr : m_OutboundTunnels) {
if(!itr->LatencyIsKnown()) continue; if(!itr->LatencyIsKnown()) continue;
auto l = itr->GetMeanLatency(); auto l = itr->GetMeanLatency();