diff --git a/llarp/iwp/session.cpp b/llarp/iwp/session.cpp index 9b850c0e6..3e15dee2f 100644 --- a/llarp/iwp/session.cpp +++ b/llarp/iwp/session.cpp @@ -180,7 +180,7 @@ namespace llarp { if (m_TXMsgs.size() >= MaxSendQueueSize) { - if(completed) + if (completed) completed(ILinkSession::DeliveryStatus::eDeliveryDropped); return false; } diff --git a/llarp/path/ihophandler.cpp b/llarp/path/ihophandler.cpp index 5768bb981..1b185e3cb 100644 --- a/llarp/path/ihophandler.cpp +++ b/llarp/path/ihophandler.cpp @@ -9,8 +9,6 @@ namespace llarp bool IHopHandler::HandleUpstream(const llarp_buffer_t& X, const TunnelNonce& Y, AbstractRouter* r) { - if (not m_UpstreamReplayFilter.Insert(Y)) - return false; if (m_UpstreamQueue == nullptr) m_UpstreamQueue = std::make_shared(); m_UpstreamQueue->emplace_back(); @@ -26,8 +24,6 @@ namespace llarp bool IHopHandler::HandleDownstream(const llarp_buffer_t& X, const TunnelNonce& Y, AbstractRouter* r) { - if (not m_DownstreamReplayFilter.Insert(Y)) - return false; if (m_DownstreamQueue == nullptr) m_DownstreamQueue = std::make_shared(); m_DownstreamQueue->emplace_back(); diff --git a/llarp/path/path.cpp b/llarp/path/path.cpp index fd55c794f..4772b8b34 100644 --- a/llarp/path/path.cpp +++ b/llarp/path/path.cpp @@ -63,6 +63,22 @@ namespace llarp m_BuiltHook = func; } + bool + Path::HandleUpstream(const llarp_buffer_t& X, const TunnelNonce& Y, AbstractRouter* r) + { + if (not m_UpstreamReplayFilter.Insert(Y)) + return false; + return IHopHandler::HandleUpstream(X, Y, r); + } + + bool + Path::HandleDownstream(const llarp_buffer_t& X, const TunnelNonce& Y, AbstractRouter* r) + { + if (not m_DownstreamReplayFilter.Insert(Y)) + return false; + return IHopHandler::HandleDownstream(X, Y, r); + } + RouterID Path::Endpoint() const { @@ -300,6 +316,8 @@ namespace llarp {"ready", IsReady()}, {"txRateCurrent", m_LastTXRate}, {"rxRateCurrent", m_LastRXRate}, + {"replayTX", m_UpstreamReplayFilter.Size()}, + {"replayRX", m_DownstreamReplayFilter.Size()}, {"hasExit", SupportsAnyRoles(ePathRoleExit)}}; std::vector hopsObj; diff --git a/llarp/path/path.hpp b/llarp/path/path.hpp index 5253f5f26..2da623079 100644 --- a/llarp/path/path.hpp +++ b/llarp/path/path.hpp @@ -200,6 +200,14 @@ namespace llarp return _status; } + // handle data in upstream direction + bool + HandleUpstream(const llarp_buffer_t& X, const TunnelNonce& Y, AbstractRouter*) override; + // handle data in downstream direction + + bool + HandleDownstream(const llarp_buffer_t& X, const TunnelNonce& Y, AbstractRouter*) override; + const std::string& ShortName() const; diff --git a/llarp/util/decaying_hashset.hpp b/llarp/util/decaying_hashset.hpp index 82c395ef4..8d5d0a5b1 100644 --- a/llarp/util/decaying_hashset.hpp +++ b/llarp/util/decaying_hashset.hpp @@ -12,8 +12,15 @@ namespace llarp { using Time_t = std::chrono::milliseconds; - DecayingHashSet(Time_t cacheInterval = 5s) : m_CacheInterval(cacheInterval) + DecayingHashSet(Time_t cacheInterval = 1s) : m_CacheInterval(cacheInterval) {} + + size_t + Size() const + { + return m_Values.size(); + } + /// determine if we have v contained in our decaying hashset bool Contains(const Val_t& v) const @@ -38,6 +45,7 @@ namespace llarp if (now == 0s) now = llarp::time_now_ms(); EraseIf([&](const auto& item) { return (m_CacheInterval + item.second) <= now; }); + m_Values.rehash(0); } Time_t