diff --git a/llarp/handlers/tun.cpp b/llarp/handlers/tun.cpp index bfbf75de6..ba4ba9877 100644 --- a/llarp/handlers/tun.cpp +++ b/llarp/handlers/tun.cpp @@ -100,7 +100,7 @@ namespace llarp { m_PacketRouter.reset( new vpn::PacketRouter{[&](net::IPPacket pkt) { HandleGotUserPacket(std::move(pkt)); }}); -#if ANDROID +#ifdef ANDROID m_Resolver = std::make_shared(r, this); m_PacketRouter->AddUDPHandler(huint16_t{53}, [&](net::IPPacket pkt) { const size_t ip_header_size = (pkt.Header()->ihl * 4); @@ -111,11 +111,10 @@ namespace llarp const SockAddr raddr{src.n, *reinterpret_cast(ptr)}; const SockAddr laddr{dst.n, *reinterpret_cast(ptr + 2)}; - std::vector buf; - buf.resize(pkt.sz - (udp_header_size + ip_header_size)); - std::copy_n(ptr + udp_header_size, buf.size(), buf.data()); + OwnedBuffer buf{pkt.sz - (udp_header_size + ip_header_size)}; + std::copy_n(ptr + udp_header_size, buf.sz, buf.buf.get()); if (m_Resolver->ShouldHandlePacket(laddr, raddr, buf)) - m_Resolver->HandlePacket(laddr, raddr, std::move(buf)); + m_Resolver->HandlePacket(laddr, raddr, buf); else HandleGotUserPacket(std::move(pkt)); }); diff --git a/llarp/net/net.cpp b/llarp/net/net.cpp index aeeeb08a4..ba5da7961 100644 --- a/llarp/net/net.cpp +++ b/llarp/net/net.cpp @@ -19,7 +19,7 @@ #include #include -#if ANDROID +#ifdef ANDROID #include #else #ifndef _WIN32 diff --git a/llarp/tooling/hive_context.cpp b/llarp/tooling/hive_context.cpp index 8171e321f..165c5f48d 100644 --- a/llarp/tooling/hive_context.cpp +++ b/llarp/tooling/hive_context.cpp @@ -8,7 +8,7 @@ namespace tooling {} std::shared_ptr - HiveContext::makeRouter(llarp::EventLoop_ptr loop) + HiveContext::makeRouter(const llarp::EventLoop_ptr& loop) { return std::make_shared(loop, makeVPNPlatform(), m_hive); } diff --git a/llarp/tooling/hive_context.hpp b/llarp/tooling/hive_context.hpp index 6a394c8b0..129f826bd 100644 --- a/llarp/tooling/hive_context.hpp +++ b/llarp/tooling/hive_context.hpp @@ -12,7 +12,7 @@ namespace tooling HiveContext(RouterHive* hive); std::shared_ptr - makeRouter(llarp::EventLoop_ptr loop) override; + makeRouter(const llarp::EventLoop_ptr& loop) override; /// Get this context's router as a HiveRouter. /// diff --git a/llarp/tooling/router_hive.cpp b/llarp/tooling/router_hive.cpp index 754e05114..f35251876 100644 --- a/llarp/tooling/router_hive.cpp +++ b/llarp/tooling/router_hive.cpp @@ -74,11 +74,11 @@ namespace tooling llarp::LogInfo("Signalling all routers to stop"); for (auto& [routerId, ctx] : relays) { - ctx->mainloop->call([ctx = ctx]() { ctx->HandleSignal(SIGINT); }); + ctx->loop->call([ctx = ctx]() { ctx->HandleSignal(SIGINT); }); } for (auto& [routerId, ctx] : clients) { - ctx->mainloop->call([ctx = ctx]() { ctx->HandleSignal(SIGINT); }); + ctx->loop->call([ctx = ctx]() { ctx->HandleSignal(SIGINT); }); } llarp::LogInfo("Waiting on routers to be stopped"); @@ -149,7 +149,7 @@ namespace tooling RouterHive::VisitRouter(Context_ptr ctx, std::function visit) { // TODO: this should be called from each router's appropriate Loop, e.g.: - // ctx->mainloop->call([visit, ctx]() { visit(ctx); }); + // ctx->loop->call([visit, ctx]() { visit(ctx); }); // however, this causes visit calls to be deferred visit(ctx); } @@ -180,7 +180,7 @@ namespace tooling size_t done_count = 0; for (auto& [routerId, ctx] : relays) { - ctx->mainloop->call([&, i, ctx = ctx]() { + ctx->loop->call([&, i, ctx = ctx]() { size_t count = ctx->router->NumberOfConnectedRouters(); std::lock_guard guard{results_lock}; results[i] = count; diff --git a/pybind/llarp/handlers/pyhandler.hpp b/pybind/llarp/handlers/pyhandler.hpp index 0e32b748b..cfbeb8526 100644 --- a/pybind/llarp/handlers/pyhandler.hpp +++ b/pybind/llarp/handlers/pyhandler.hpp @@ -76,7 +76,7 @@ namespace llarp void SendPacket(service::Address remote, std::vector pkt, service::ProtocolType proto) { - LogicCall(m_router->logic(), [remote, pkt, proto, self = shared_from_this()]() { + m_router->loop()->call([remote, pkt, proto, self = shared_from_this()]() { self->SendToServiceOrQueue(remote, llarp_buffer_t(pkt), proto); }); } diff --git a/pybind/llarp/router.cpp b/pybind/llarp/router.cpp index ad668f4b8..778f566c3 100644 --- a/pybind/llarp/router.cpp +++ b/pybind/llarp/router.cpp @@ -8,7 +8,7 @@ namespace llarp void AbstractRouter_Init(py::module& mod) { - py::class_(mod, "AbstractRouter") + py::class_>(mod, "AbstractRouter") .def("rc", &AbstractRouter::rc) .def("Stop", &AbstractRouter::Stop) .def("peerDb", &AbstractRouter::peerDb); @@ -21,7 +21,7 @@ namespace tooling void HiveRouter_Init(py::module& mod) { - py::class_(mod, "HiveRouter") + py::class_>(mod, "HiveRouter") .def("disableGossiping", &HiveRouter::disableGossiping) .def("enableGossiping", &HiveRouter::enableGossiping); }