1
1
Fork 0
mirror of https://github.com/oxen-io/lokinet synced 2023-12-14 06:53:00 +01:00
lokinet/llarp/path/ihophandler.cpp

47 lines
1.3 KiB
C++
Raw Normal View History

2019-06-18 01:19:39 +02:00
#include <path/ihophandler.hpp>
2019-09-16 18:21:21 +02:00
namespace llarp
{
namespace path
{
// handle data in upstream direction
bool
IHopHandler::HandleUpstream(const llarp_buffer_t& X, const TunnelNonce& Y, AbstractRouter*)
2019-09-16 18:21:21 +02:00
{
if (not m_UpstreamReplayFilter.Insert(Y))
return false;
if (m_UpstreamQueue == nullptr)
m_UpstreamQueue = std::make_shared<TrafficQueue_t>();
2019-09-16 18:21:21 +02:00
m_UpstreamQueue->emplace_back();
auto& pkt = m_UpstreamQueue->back();
pkt.first.resize(X.sz);
std::copy_n(X.base, X.sz, pkt.first.begin());
pkt.second = Y;
return true;
}
// handle data in downstream direction
bool
IHopHandler::HandleDownstream(const llarp_buffer_t& X, const TunnelNonce& Y, AbstractRouter*)
2019-09-16 18:21:21 +02:00
{
if (not m_DownstreamReplayFilter.Insert(Y))
return false;
if (m_DownstreamQueue == nullptr)
m_DownstreamQueue = std::make_shared<TrafficQueue_t>();
2019-09-16 18:21:21 +02:00
m_DownstreamQueue->emplace_back();
auto& pkt = m_DownstreamQueue->back();
pkt.first.resize(X.sz);
std::copy_n(X.base, X.sz, pkt.first.begin());
pkt.second = Y;
return true;
}
void
IHopHandler::DecayFilters(llarp_time_t now)
{
m_UpstreamReplayFilter.Decay(now);
m_DownstreamReplayFilter.Decay(now);
}
2019-09-16 18:21:21 +02:00
} // namespace path
2020-01-03 12:04:47 +01:00
} // namespace llarp