mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-11-03 23:15:52 +00:00
95cd275cdd
* add lokinet_add_bootstrap_rc function for adding an rc from memory * prevent stack overflow on error closing connection in quic * add in memory nodedb * refactor how convotags are set as active * add initial stubs for endpoint statistics * refactor time stuff to be a bit cleaner * update lnproxy script with more arguments
86 lines
2.1 KiB
C++
86 lines
2.1 KiB
C++
#pragma once
|
|
|
|
#include <llarp/service/endpoint.hpp>
|
|
#include <llarp/service/protocol_type.hpp>
|
|
#include <llarp/quic/tunnel.hpp>
|
|
#include <llarp/router/abstractrouter.hpp>
|
|
#include <llarp/ev/ev.hpp>
|
|
|
|
namespace llarp
|
|
{
|
|
namespace handlers
|
|
{
|
|
struct NullEndpoint final : public llarp::service::Endpoint,
|
|
public std::enable_shared_from_this<NullEndpoint>
|
|
{
|
|
NullEndpoint(AbstractRouter* r, llarp::service::Context* parent)
|
|
: llarp::service::Endpoint(r, parent)
|
|
{
|
|
r->loop()->add_ticker([this] { Pump(Now()); });
|
|
}
|
|
|
|
virtual bool
|
|
HandleInboundPacket(
|
|
const service::ConvoTag tag,
|
|
const llarp_buffer_t& buf,
|
|
service::ProtocolType t,
|
|
uint64_t) override
|
|
{
|
|
LogTrace("Inbound ", t, " packet (", buf.sz, "B) on convo ", tag);
|
|
if (t == service::ProtocolType::Control)
|
|
{
|
|
return true;
|
|
}
|
|
if (t != service::ProtocolType::QUIC)
|
|
return false;
|
|
|
|
auto* quic = GetQUICTunnel();
|
|
if (!quic)
|
|
{
|
|
LogWarn("incoming quic packet but this endpoint is not quic capable; dropping");
|
|
return false;
|
|
}
|
|
if (buf.sz < 4)
|
|
{
|
|
LogWarn("invalid incoming quic packet, dropping");
|
|
return false;
|
|
}
|
|
quic->receive_packet(tag, buf);
|
|
return true;
|
|
}
|
|
|
|
std::string
|
|
GetIfName() const override
|
|
{
|
|
return "";
|
|
}
|
|
|
|
path::PathSet_ptr
|
|
GetSelf() override
|
|
{
|
|
return shared_from_this();
|
|
}
|
|
|
|
bool
|
|
SupportsV6() const override
|
|
{
|
|
return false;
|
|
}
|
|
|
|
void
|
|
SendPacketToRemote(const llarp_buffer_t&, service::ProtocolType) override{};
|
|
|
|
huint128_t ObtainIPForAddr(std::variant<service::Address, RouterID>) override
|
|
{
|
|
return {0};
|
|
}
|
|
|
|
std::optional<std::variant<service::Address, RouterID>> ObtainAddrForIP(
|
|
huint128_t) const override
|
|
{
|
|
return std::nullopt;
|
|
}
|
|
};
|
|
} // namespace handlers
|
|
} // namespace llarp
|