2021-03-09 22:24:35 +00:00
|
|
|
#pragma once
|
2018-12-12 02:15:08 +00:00
|
|
|
|
2021-03-09 22:24:35 +00:00
|
|
|
#include <llarp/service/endpoint.hpp>
|
2021-03-27 18:54:09 +00:00
|
|
|
#include <llarp/service/protocol_type.hpp>
|
|
|
|
#include <llarp/quic/tunnel.hpp>
|
|
|
|
#include <llarp/router/abstractrouter.hpp>
|
|
|
|
#include <llarp/ev/ev.hpp>
|
2018-11-29 13:12:35 +00:00
|
|
|
|
2018-12-02 18:07:07 +00:00
|
|
|
namespace llarp
|
2018-11-29 13:12:35 +00:00
|
|
|
{
|
2018-12-02 18:07:07 +00:00
|
|
|
namespace handlers
|
2018-11-29 13:12:35 +00:00
|
|
|
{
|
2020-04-07 18:38:56 +00:00
|
|
|
struct NullEndpoint final : public llarp::service::Endpoint,
|
|
|
|
public std::enable_shared_from_this<NullEndpoint>
|
2018-11-29 13:12:35 +00:00
|
|
|
{
|
2020-04-30 19:40:20 +00:00
|
|
|
NullEndpoint(AbstractRouter* r, llarp::service::Context* parent)
|
|
|
|
: llarp::service::Endpoint(r, parent)
|
2021-03-27 18:54:09 +00:00
|
|
|
{
|
2021-04-01 11:13:39 +00:00
|
|
|
r->loop()->add_ticker([this] { Pump(Now()); });
|
2021-03-27 18:54:09 +00:00
|
|
|
}
|
2018-11-29 13:12:35 +00:00
|
|
|
|
2020-02-28 16:29:15 +00:00
|
|
|
virtual bool
|
2020-04-07 18:38:56 +00:00
|
|
|
HandleInboundPacket(
|
2021-03-27 18:54:09 +00:00
|
|
|
const service::ConvoTag tag,
|
|
|
|
const llarp_buffer_t& buf,
|
|
|
|
service::ProtocolType t,
|
2021-04-01 11:13:39 +00:00
|
|
|
uint64_t) override
|
2018-11-29 13:12:35 +00:00
|
|
|
{
|
2021-04-01 01:40:29 +00:00
|
|
|
LogTrace("Inbound ", t, " packet (", buf.sz, "B) on convo ", tag);
|
2021-03-29 16:31:55 +00:00
|
|
|
if (t == service::ProtocolType::Control)
|
2021-03-31 17:09:34 +00:00
|
|
|
{
|
2021-03-29 16:31:55 +00:00
|
|
|
return true;
|
2021-03-31 17:09:34 +00:00
|
|
|
}
|
2021-03-29 16:31:55 +00:00
|
|
|
if (t != service::ProtocolType::QUIC)
|
2021-03-27 18:54:09 +00:00
|
|
|
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;
|
|
|
|
}
|
2021-04-01 11:13:39 +00:00
|
|
|
quic->receive_packet(tag, buf);
|
2018-11-29 13:12:35 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-08-21 15:07:37 +00:00
|
|
|
std::string
|
|
|
|
GetIfName() const override
|
|
|
|
{
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2019-04-23 16:13:22 +00:00
|
|
|
path::PathSet_ptr
|
|
|
|
GetSelf() override
|
|
|
|
{
|
|
|
|
return shared_from_this();
|
|
|
|
}
|
|
|
|
|
2019-06-11 16:44:05 +00:00
|
|
|
bool
|
|
|
|
SupportsV6() const override
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2020-05-21 14:18:23 +00:00
|
|
|
|
|
|
|
void
|
2021-03-16 11:56:27 +00:00
|
|
|
SendPacketToRemote(const llarp_buffer_t&, service::ProtocolType) override{};
|
2020-08-20 12:59:01 +00:00
|
|
|
|
2021-03-15 16:01:19 +00:00
|
|
|
huint128_t ObtainIPForAddr(std::variant<service::Address, RouterID>) override
|
2020-08-20 12:59:01 +00:00
|
|
|
{
|
|
|
|
return {0};
|
|
|
|
}
|
2021-03-15 16:01:19 +00:00
|
|
|
|
|
|
|
std::optional<std::variant<service::Address, RouterID>> ObtainAddrForIP(
|
|
|
|
huint128_t) const override
|
|
|
|
{
|
|
|
|
return std::nullopt;
|
|
|
|
}
|
2018-11-29 13:12:35 +00:00
|
|
|
};
|
2018-12-02 18:07:07 +00:00
|
|
|
} // namespace handlers
|
|
|
|
} // namespace llarp
|