diff --git a/CMakeLists.txt b/CMakeLists.txt index 57aa6e4f7..6e190c707 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,9 @@ project(${PROJECT_NAME} C CXX) option(USE_AVX2 "enable avx2 code" ) option(USE_NETNS "enable networking namespace support. Linux only" ) option(AMD_RYZEN_HACK "hack for AMD Ryzen FPU bug (support FMA3 and FMA4 in FPU, but does not show in CPUID)" ) +if (NOT MSVC) option(STATIC_LINK_RUNTIME "link statically against compiler runtime, standard library and pthreads") +endif() option(NON_PC_TARGET "non-pc target build: iphone, andriod, embedded non-i386 SBC, etc" ) option(SHADOW "use shadow testing framework. linux only" ) option(ASAN "use address sanitiser, if your system has it" ) @@ -76,8 +78,10 @@ if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Linux" AND SHADOW) endif(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Linux" AND SHADOW) if (WIN32 AND NOT STATIC_LINK_RUNTIME) - message("must ship compiler runtime libraries with this build: libwinpthread-1.dll, libgcc_s_dw2-1.dll, and libstdc++-6.dll") - message("for release builds, turn on STATIC_LINK_RUNTIME in cmake options") + if(NOT MSVC) + message("must ship compiler runtime libraries with this build: libwinpthread-1.dll, libgcc_s_dw2-1.dll, and libstdc++-6.dll") + message("for release builds, turn on STATIC_LINK_RUNTIME in cmake options") + endif() endif(WIN32 AND NOT STATIC_LINK_RUNTIME) add_subdirectory(vendor/cxxopts) diff --git a/daemon/main.cpp b/daemon/main.cpp index b370a970f..cf9e2bf41 100644 --- a/daemon/main.cpp +++ b/daemon/main.cpp @@ -186,7 +186,7 @@ main(int argc, char *argv[]) // does this file exist? if(genconfigOnly) { - if(!llarp_ensure_config(conffname.c_str(), basedir.c_str(), overWrite, + if(!llarp_ensure_config(conffname.c_str(), basedir.string().c_str(), overWrite, asRouter)) return 1; } diff --git a/llarp/CMakeLists.txt b/llarp/CMakeLists.txt index ad71475e9..00855b21a 100644 --- a/llarp/CMakeLists.txt +++ b/llarp/CMakeLists.txt @@ -222,19 +222,18 @@ set(LIB_SRC service/endpoint.cpp service/handler.cpp service/hidden_service_address_lookup.cpp - service/Identity.cpp + service/identity.cpp service/info.cpp - service/Intro.cpp - service/IntroSet.cpp + service/intro_set.cpp + service/intro.cpp service/lookup.cpp service/outbound_context.cpp service/pendingbuffer.cpp service/protocol.cpp service/sendcontext.cpp service/session.cpp - service/tag.cpp service/tag_lookup_job.cpp - service/types.cpp + service/tag.cpp service/vanity.cpp utp/inbound_message.cpp utp/linklayer.cpp diff --git a/llarp/dht/context.cpp b/llarp/dht/context.cpp index 7aedcf966..d412e1c63 100644 --- a/llarp/dht/context.cpp +++ b/llarp/dht/context.cpp @@ -135,7 +135,7 @@ namespace llarp /// relay a dht message from a local path to the main network bool RelayRequestForPath(const llarp::PathID_t& localPath, - const IMessage* msg) override; + const IMessage& msg) override; /// send introset to peer from source with S counter and excluding peers void @@ -540,15 +540,15 @@ namespace llarp } bool - Context::RelayRequestForPath(const llarp::PathID_t& id, const IMessage* msg) + Context::RelayRequestForPath(const llarp::PathID_t& id, const IMessage& msg) { llarp::routing::DHTMessage reply; - if(!msg->HandleMessage(router->dht(), reply.M)) + if(!msg.HandleMessage(router->dht(), reply.M)) return false; if(!reply.M.empty()) { auto path = router->pathContext().GetByUpstream(router->pubkey(), id); - return path && path->SendRoutingMessage(&reply, router); + return path && path->SendRoutingMessage(reply, router); } return true; } diff --git a/llarp/dht/context.hpp b/llarp/dht/context.hpp index 5173a5a97..b0789c567 100644 --- a/llarp/dht/context.hpp +++ b/llarp/dht/context.hpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include @@ -107,7 +107,7 @@ namespace llarp std::vector< std::unique_ptr< IMessage > >& replies) = 0; virtual bool - RelayRequestForPath(const PathID_t& localPath, const IMessage* msg) = 0; + RelayRequestForPath(const PathID_t& localPath, const IMessage& msg) = 0; /// send introset to peer from source with S counter and excluding peers virtual void diff --git a/llarp/dht/localrouterlookup.cpp b/llarp/dht/localrouterlookup.cpp index 6f7c33fa7..d33fcf680 100644 --- a/llarp/dht/localrouterlookup.cpp +++ b/llarp/dht/localrouterlookup.cpp @@ -47,7 +47,7 @@ namespace llarp routing::DHTMessage msg; msg.M.emplace_back(new GotRouterMessage(parent->OurKey(), whoasked.txid, valuesFound, true)); - if(!path->SendRoutingMessage(&msg, parent->GetRouter())) + if(!path->SendRoutingMessage(msg, parent->GetRouter())) { llarp::LogWarn( "failed to send routing message when informing result of dht " diff --git a/llarp/dht/localserviceaddresslookup.cpp b/llarp/dht/localserviceaddresslookup.cpp index 187b5331a..c5797ea05 100644 --- a/llarp/dht/localserviceaddresslookup.cpp +++ b/llarp/dht/localserviceaddresslookup.cpp @@ -47,7 +47,7 @@ namespace llarp } routing::DHTMessage msg; msg.M.emplace_back(new GotIntroMessage(valuesFound, whoasked.txid)); - if(!path->SendRoutingMessage(&msg, parent->GetRouter())) + if(!path->SendRoutingMessage(msg, parent->GetRouter())) { llarp::LogWarn( "failed to send routing message when informing result of dht " diff --git a/llarp/dht/localtaglookup.cpp b/llarp/dht/localtaglookup.cpp index a0cfb6d20..4750a6366 100644 --- a/llarp/dht/localtaglookup.cpp +++ b/llarp/dht/localtaglookup.cpp @@ -33,7 +33,7 @@ namespace llarp } routing::DHTMessage msg; msg.M.emplace_back(new GotIntroMessage(valuesFound, whoasked.txid)); - if(!path->SendRoutingMessage(&msg, parent->GetRouter())) + if(!path->SendRoutingMessage(msg, parent->GetRouter())) { llarp::LogWarn( "failed to send routing message when informing result of dht " diff --git a/llarp/dht/messages/gotintro.hpp b/llarp/dht/messages/gotintro.hpp index 5ae6c9285..8d511b37f 100644 --- a/llarp/dht/messages/gotintro.hpp +++ b/llarp/dht/messages/gotintro.hpp @@ -2,7 +2,7 @@ #define LLARP_DHT_MESSAGES_GOT_INTRO_HPP #include -#include +#include #include diff --git a/llarp/dht/messages/pubintro.hpp b/llarp/dht/messages/pubintro.hpp index d9348c913..6854965d1 100644 --- a/llarp/dht/messages/pubintro.hpp +++ b/llarp/dht/messages/pubintro.hpp @@ -1,7 +1,7 @@ #ifndef LLARP_DHT_MESSAGES_PUB_INTRO_HPP #define LLARP_DHT_MESSAGES_PUB_INTRO_HPP #include -#include +#include #include diff --git a/llarp/dht/node.hpp b/llarp/dht/node.hpp index 8cd778ade..59cb96372 100644 --- a/llarp/dht/node.hpp +++ b/llarp/dht/node.hpp @@ -3,7 +3,7 @@ #include #include -#include +#include namespace llarp { diff --git a/llarp/dht/publishservicejob.hpp b/llarp/dht/publishservicejob.hpp index b69877cbc..52da0993e 100644 --- a/llarp/dht/publishservicejob.hpp +++ b/llarp/dht/publishservicejob.hpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include diff --git a/llarp/dht/serviceaddresslookup.hpp b/llarp/dht/serviceaddresslookup.hpp index 708eac5d0..122ea31a0 100644 --- a/llarp/dht/serviceaddresslookup.hpp +++ b/llarp/dht/serviceaddresslookup.hpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include namespace llarp { diff --git a/llarp/dht/taglookup.cpp b/llarp/dht/taglookup.cpp index af7760081..ccca855ea 100644 --- a/llarp/dht/taglookup.cpp +++ b/llarp/dht/taglookup.cpp @@ -35,6 +35,7 @@ namespace llarp { std::set< service::IntroSet > found(valuesFound.begin(), valuesFound.end()); + // collect our local values if we haven't hit a limit if(found.size() < 2) { diff --git a/llarp/dht/taglookup.hpp b/llarp/dht/taglookup.hpp index e028af7e5..bb8ebe212 100644 --- a/llarp/dht/taglookup.hpp +++ b/llarp/dht/taglookup.hpp @@ -2,7 +2,7 @@ #define LLARP_DHT_TAGLOOKUP #include -#include +#include #include namespace llarp diff --git a/llarp/exit/close_exit.cpp b/llarp/exit/close_exit.cpp index 3af088a24..4f8d5809c 100644 --- a/llarp/exit/close_exit.cpp +++ b/llarp/exit/close_exit.cpp @@ -79,7 +79,7 @@ namespace llarp bool CloseExitMessage::HandleMessage(IMessageHandler* h, AbstractRouter* r) const { - return h->HandleCloseExitMessage(this, r); + return h->HandleCloseExitMessage(*this, r); } } // namespace routing diff --git a/llarp/exit/endpoint.cpp b/llarp/exit/endpoint.cpp index 69932ae89..58e2d0bc3 100644 --- a/llarp/exit/endpoint.cpp +++ b/llarp/exit/endpoint.cpp @@ -176,7 +176,7 @@ namespace llarp { auto& msg = queue.front(); msg.S = path->NextSeqNo(); - if(path->SendRoutingMessage(&msg, m_Parent->GetRouter())) + if(path->SendRoutingMessage(msg, m_Parent->GetRouter())) { m_RxRate += msg.Size(); sent = true; diff --git a/llarp/exit/grant_exit.cpp b/llarp/exit/grant_exit.cpp index 07df83e03..50c533092 100644 --- a/llarp/exit/grant_exit.cpp +++ b/llarp/exit/grant_exit.cpp @@ -85,7 +85,7 @@ namespace llarp bool GrantExitMessage::HandleMessage(IMessageHandler* h, AbstractRouter* r) const { - return h->HandleGrantExitMessage(this, r); + return h->HandleGrantExitMessage(*this, r); } } // namespace routing diff --git a/llarp/exit/obtain_exit.cpp b/llarp/exit/obtain_exit.cpp index bd720dbe1..ac769d3a2 100644 --- a/llarp/exit/obtain_exit.cpp +++ b/llarp/exit/obtain_exit.cpp @@ -96,7 +96,7 @@ namespace llarp ObtainExitMessage::HandleMessage(IMessageHandler* h, AbstractRouter* r) const { - return h->HandleObtainExitMessage(this, r); + return h->HandleObtainExitMessage(*this, r); } } // namespace routing diff --git a/llarp/exit/reject_exit.cpp b/llarp/exit/reject_exit.cpp index 4d3038ba1..812feeba8 100644 --- a/llarp/exit/reject_exit.cpp +++ b/llarp/exit/reject_exit.cpp @@ -96,7 +96,7 @@ namespace llarp RejectExitMessage::HandleMessage(IMessageHandler* h, AbstractRouter* r) const { - return h->HandleRejectExitMessage(this, r); + return h->HandleRejectExitMessage(*this, r); } } // namespace routing diff --git a/llarp/exit/session.cpp b/llarp/exit/session.cpp index 4fc8d7aae..476a4f158 100644 --- a/llarp/exit/session.cpp +++ b/llarp/exit/session.cpp @@ -107,7 +107,7 @@ namespace llarp llarp::LogError("Failed to sign exit request"); return; } - if(p->SendExitRequest(&obtain, router)) + if(p->SendExitRequest(obtain, router)) llarp::LogInfo("asking ", m_ExitRouter, " for exit"); else llarp::LogError("failed to send exit request"); @@ -156,7 +156,7 @@ namespace llarp llarp::LogInfo(p->Name(), " closing exit path"); llarp::routing::CloseExitMessage msg; if(!(msg.Sign(router->crypto(), m_ExitIdentity) - && p->SendExitClose(&msg, router))) + && p->SendExitClose(msg, router))) llarp::LogWarn(p->Name(), " failed to send exit close message"); } }; @@ -244,7 +244,7 @@ namespace llarp { auto& msg = queue.front(); msg.S = path->NextSeqNo(); - if(path->SendRoutingMessage(&msg, router)) + if(path->SendRoutingMessage(msg, router)) m_LastUse = now; queue.pop_front(); } diff --git a/llarp/exit/transfer_traffic.cpp b/llarp/exit/transfer_traffic.cpp index 2058781a1..a3d1142e7 100644 --- a/llarp/exit/transfer_traffic.cpp +++ b/llarp/exit/transfer_traffic.cpp @@ -66,7 +66,7 @@ namespace llarp TransferTrafficMessage::HandleMessage(IMessageHandler* h, AbstractRouter* r) const { - return h->HandleTransferTrafficMessage(this, r); + return h->HandleTransferTrafficMessage(*this, r); } } // namespace routing diff --git a/llarp/exit/update_exit.cpp b/llarp/exit/update_exit.cpp index 9b08db6a1..a6a782bb2 100644 --- a/llarp/exit/update_exit.cpp +++ b/llarp/exit/update_exit.cpp @@ -87,7 +87,7 @@ namespace llarp UpdateExitMessage::HandleMessage(IMessageHandler* h, AbstractRouter* r) const { - return h->HandleUpdateExitMessage(this, r); + return h->HandleUpdateExitMessage(*this, r); } bool @@ -124,7 +124,7 @@ namespace llarp UpdateExitVerifyMessage::HandleMessage(IMessageHandler* h, AbstractRouter* r) const { - return h->HandleUpdateExitVerifyMessage(this, r); + return h->HandleUpdateExitVerifyMessage(*this, r); } } // namespace routing diff --git a/llarp/messages/discard.hpp b/llarp/messages/discard.hpp index be34fc43b..67334219e 100644 --- a/llarp/messages/discard.hpp +++ b/llarp/messages/discard.hpp @@ -75,7 +75,7 @@ namespace llarp bool HandleMessage(IMessageHandler* h, AbstractRouter* r) const override { - return h->HandleDataDiscardMessage(this, r); + return h->HandleDataDiscardMessage(*this, r); } bool diff --git a/llarp/messages/relay_commit.cpp b/llarp/messages/relay_commit.cpp index 3cc1f02d2..a2c19301c 100644 --- a/llarp/messages/relay_commit.cpp +++ b/llarp/messages/relay_commit.cpp @@ -275,7 +275,7 @@ namespace llarp self->context->PutTransitHop(self->hop); // send path confirmation llarp::routing::PathConfirmMessage confirm(self->hop->lifetime); - if(!self->hop->SendRoutingMessage(&confirm, self->context->Router())) + if(!self->hop->SendRoutingMessage(confirm, self->context->Router())) { llarp::LogError("failed to send path confirmation for ", self->hop->info); diff --git a/llarp/path/path.cpp b/llarp/path/path.cpp index 35dd5471a..54decdb2a 100644 --- a/llarp/path/path.cpp +++ b/llarp/path/path.cpp @@ -174,7 +174,7 @@ namespace llarp { auto own = MapGet( m_OurPaths, id, - [](__attribute__((unused)) const PathSet* s) -> bool { + [](ABSL_ATTRIBUTE_UNUSED const PathSet* s) -> bool { // TODO: is this right? return true; }, @@ -574,7 +574,7 @@ namespace llarp latency.T = randint(); m_LastLatencyTestID = latency.T; m_LastLatencyTestTime = now; - SendRoutingMessage(&latency, r); + SendRoutingMessage(latency, r); return; } if(m_LastRecvMessage && now > m_LastRecvMessage) @@ -667,15 +667,15 @@ namespace llarp bool Path::HandleUpdateExitVerifyMessage( - const routing::UpdateExitVerifyMessage* msg, AbstractRouter* r) + const routing::UpdateExitVerifyMessage& msg, AbstractRouter* r) { (void)r; - if(m_UpdateExitTX && msg->T == m_UpdateExitTX) + if(m_UpdateExitTX && msg.T == m_UpdateExitTX) { if(m_ExitUpdated) return m_ExitUpdated(this); } - if(m_CloseExitTX && msg->T == m_CloseExitTX) + if(m_CloseExitTX && msg.T == m_CloseExitTX) { if(m_ExitClosed) return m_ExitClosed(this); @@ -684,15 +684,15 @@ namespace llarp } bool - Path::SendRoutingMessage(const routing::IMessage* msg, AbstractRouter* r) + Path::SendRoutingMessage(const routing::IMessage& msg, AbstractRouter* r) { std::array< byte_t, MAX_LINK_MSG_SIZE / 2 > tmp; llarp_buffer_t buf(tmp); // should help prevent bad paths with uninitialized members // FIXME: Why would we get uninitialized IMessages? - if(msg->version != LLARP_PROTO_VERSION) + if(msg.version != LLARP_PROTO_VERSION) return false; - if(!msg->BEncode(&buf)) + if(!msg.BEncode(&buf)) { LogError("Bencode failed"); DumpBuffer(buf); @@ -714,9 +714,9 @@ namespace llarp } bool - Path::HandlePathTransferMessage(__attribute__((unused)) - const routing::PathTransferMessage* msg, - __attribute__((unused)) AbstractRouter* r) + Path::HandlePathTransferMessage( + ABSL_ATTRIBUTE_UNUSED const routing::PathTransferMessage& msg, + ABSL_ATTRIBUTE_UNUSED AbstractRouter* r) { LogWarn("unwarranted path transfer message on tx=", TXID(), " rx=", RXID()); @@ -724,19 +724,19 @@ namespace llarp } bool - Path::HandleDataDiscardMessage(const routing::DataDiscardMessage* msg, + Path::HandleDataDiscardMessage(const routing::DataDiscardMessage& msg, AbstractRouter* r) { MarkActive(r->Now()); if(m_DropHandler) - return m_DropHandler(this, msg->P, msg->S); + return m_DropHandler(this, msg.P, msg.S); return true; } bool - Path::HandlePathConfirmMessage(__attribute__((unused)) - const routing::PathConfirmMessage* msg, - AbstractRouter* r) + Path::HandlePathConfirmMessage( + ABSL_ATTRIBUTE_UNUSED const routing::PathConfirmMessage& msg, + AbstractRouter* r) { auto now = r->Now(); if(_status == ePathBuilding) @@ -754,7 +754,7 @@ namespace llarp latency.T = randint(); m_LastLatencyTestID = latency.T; m_LastLatencyTestTime = now; - return SendRoutingMessage(&latency, r); + return SendRoutingMessage(latency, r); } LogWarn("got unwarranted path confirm message on tx=", RXID(), " rx=", RXID()); @@ -762,19 +762,19 @@ namespace llarp } bool - Path::HandleHiddenServiceFrame(const service::ProtocolFrame* frame) + Path::HandleHiddenServiceFrame(const service::ProtocolFrame& frame) { MarkActive(m_PathSet->Now()); return m_DataHandler && m_DataHandler(this, frame); } bool - Path::HandlePathLatencyMessage(const routing::PathLatencyMessage* msg, + Path::HandlePathLatencyMessage(const routing::PathLatencyMessage& msg, AbstractRouter* r) { auto now = r->Now(); MarkActive(now); - if(msg->L == m_LastLatencyTestID) + if(msg.L == m_LastLatencyTestID) { intro.latency = now - m_LastLatencyTestTime; m_LastLatencyTestID = 0; @@ -793,25 +793,25 @@ namespace llarp } bool - Path::HandleDHTMessage(const dht::IMessage* msg, AbstractRouter* r) + Path::HandleDHTMessage(const dht::IMessage& msg, AbstractRouter* r) { MarkActive(r->Now()); routing::DHTMessage reply; - if(!msg->HandleMessage(r->dht(), reply.M)) + if(!msg.HandleMessage(r->dht(), reply.M)) return false; if(reply.M.size()) - return SendRoutingMessage(&reply, r); + return SendRoutingMessage(reply, r); return true; } bool - Path::HandleCloseExitMessage(const routing::CloseExitMessage* msg, + Path::HandleCloseExitMessage(const routing::CloseExitMessage& msg, AbstractRouter* r) { /// allows exits to close from their end if(SupportsAnyRoles(ePathRoleExit | ePathRoleSVC)) { - if(msg->Verify(r->crypto(), EndpointPubKey())) + if(msg.Verify(r->crypto(), EndpointPubKey())) { LogInfo(Name(), " had its exit closed"); _role &= ~ePathRoleExit; @@ -826,16 +826,16 @@ namespace llarp } bool - Path::SendExitRequest(const routing::ObtainExitMessage* msg, + Path::SendExitRequest(const routing::ObtainExitMessage& msg, AbstractRouter* r) { LogInfo(Name(), " sending exit request to ", Endpoint()); - m_ExitObtainTX = msg->T; + m_ExitObtainTX = msg.T; return SendRoutingMessage(msg, r); } bool - Path::SendExitClose(const routing::CloseExitMessage* msg, AbstractRouter* r) + Path::SendExitClose(const routing::CloseExitMessage& msg, AbstractRouter* r) { LogInfo(Name(), " closing exit to ", Endpoint()); // mark as not exit anymore @@ -844,7 +844,7 @@ namespace llarp } bool - Path::HandleObtainExitMessage(const routing::ObtainExitMessage* msg, + Path::HandleObtainExitMessage(const routing::ObtainExitMessage& msg, AbstractRouter* r) { (void)msg; @@ -854,7 +854,7 @@ namespace llarp } bool - Path::HandleUpdateExitMessage(const routing::UpdateExitMessage* msg, + Path::HandleUpdateExitMessage(const routing::UpdateExitMessage& msg, AbstractRouter* r) { (void)msg; @@ -864,31 +864,31 @@ namespace llarp } bool - Path::HandleRejectExitMessage(const routing::RejectExitMessage* msg, + Path::HandleRejectExitMessage(const routing::RejectExitMessage& msg, AbstractRouter* r) { - if(m_ExitObtainTX && msg->T == m_ExitObtainTX) + if(m_ExitObtainTX && msg.T == m_ExitObtainTX) { - if(!msg->Verify(r->crypto(), EndpointPubKey())) + if(!msg.Verify(r->crypto(), EndpointPubKey())) { LogError(Name(), "RXM invalid signature"); return false; } LogInfo(Name(), " ", Endpoint(), " Rejected exit"); MarkActive(r->Now()); - return InformExitResult(msg->B); + return InformExitResult(msg.B); } LogError(Name(), " got unwarranted RXM"); return false; } bool - Path::HandleGrantExitMessage(const routing::GrantExitMessage* msg, + Path::HandleGrantExitMessage(const routing::GrantExitMessage& msg, AbstractRouter* r) { - if(m_ExitObtainTX && msg->T == m_ExitObtainTX) + if(m_ExitObtainTX && msg.T == m_ExitObtainTX) { - if(!msg->Verify(r->crypto(), EndpointPubKey())) + if(!msg.Verify(r->crypto(), EndpointPubKey())) { LogError(Name(), " GXM signature failed"); return false; @@ -915,7 +915,7 @@ namespace llarp bool Path::HandleTransferTrafficMessage( - const routing::TransferTrafficMessage* msg, AbstractRouter* r) + const routing::TransferTrafficMessage& msg, AbstractRouter* r) { // check if we can handle exit data if(!SupportsAnyRoles(ePathRoleExit | ePathRoleSVC)) @@ -923,8 +923,8 @@ namespace llarp // handle traffic if we have a handler if(!m_ExitTrafficHandler) return false; - bool sent = msg->X.size() > 0; - for(const auto& pkt : msg->X) + bool sent = msg.X.size() > 0; + for(const auto& pkt : msg.X) { if(pkt.size() <= 8) return false; diff --git a/llarp/path/path.hpp b/llarp/path/path.hpp index cf6942f9b..52dfa0eba 100644 --- a/llarp/path/path.hpp +++ b/llarp/path/path.hpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include #include @@ -123,8 +123,7 @@ namespace llarp /// send routing message and increment sequence number virtual bool - SendRoutingMessage(const llarp::routing::IMessage* msg, - llarp::AbstractRouter* r) = 0; + SendRoutingMessage(const routing::IMessage& msg, AbstractRouter* r) = 0; // handle data in upstream direction virtual bool @@ -150,8 +149,7 @@ namespace llarp uint64_t m_SequenceNum = 0; }; - struct TransitHop : public IHopHandler, - public llarp::routing::IMessageHandler + struct TransitHop : public IHopHandler, public routing::IMessageHandler { TransitHop(); @@ -195,72 +193,68 @@ namespace llarp // send routing message when end of path bool - SendRoutingMessage(const llarp::routing::IMessage* msg, + SendRoutingMessage(const routing::IMessage& msg, AbstractRouter* r) override; // handle routing message when end of path bool - HandleRoutingMessage(const llarp::routing::IMessage* msg, - AbstractRouter* r); + HandleRoutingMessage(const routing::IMessage& msg, AbstractRouter* r); bool - HandleDataDiscardMessage(const llarp::routing::DataDiscardMessage* msg, + HandleDataDiscardMessage(const routing::DataDiscardMessage& msg, AbstractRouter* r) override; bool - HandlePathConfirmMessage(const llarp::routing::PathConfirmMessage* msg, + HandlePathConfirmMessage(const routing::PathConfirmMessage& msg, AbstractRouter* r) override; bool - HandlePathTransferMessage(const llarp::routing::PathTransferMessage* msg, + HandlePathTransferMessage(const routing::PathTransferMessage& msg, AbstractRouter* r) override; bool - HandlePathLatencyMessage(const llarp::routing::PathLatencyMessage* msg, + HandlePathLatencyMessage(const routing::PathLatencyMessage& msg, AbstractRouter* r) override; bool - HandleObtainExitMessage(const llarp::routing::ObtainExitMessage* msg, + HandleObtainExitMessage(const routing::ObtainExitMessage& msg, AbstractRouter* r) override; bool - HandleUpdateExitVerifyMessage( - const llarp::routing::UpdateExitVerifyMessage* msg, - AbstractRouter* r) override; + HandleUpdateExitVerifyMessage(const routing::UpdateExitVerifyMessage& msg, + AbstractRouter* r) override; bool - HandleTransferTrafficMessage( - const llarp::routing::TransferTrafficMessage* msg, - AbstractRouter* r) override; + HandleTransferTrafficMessage(const routing::TransferTrafficMessage& msg, + AbstractRouter* r) override; bool - HandleUpdateExitMessage(const llarp::routing::UpdateExitMessage* msg, + HandleUpdateExitMessage(const routing::UpdateExitMessage& msg, AbstractRouter* r) override; bool - HandleGrantExitMessage(const llarp::routing::GrantExitMessage* msg, + HandleGrantExitMessage(const routing::GrantExitMessage& msg, AbstractRouter* r) override; bool - HandleRejectExitMessage(const llarp::routing::RejectExitMessage* msg, + HandleRejectExitMessage(const routing::RejectExitMessage& msg, AbstractRouter* r) override; bool - HandleCloseExitMessage(const llarp::routing::CloseExitMessage* msg, + HandleCloseExitMessage(const routing::CloseExitMessage& msg, AbstractRouter* r) override; bool - HandleHiddenServiceFrame(__attribute__(( - unused)) const llarp::service::ProtocolFrame* frame) override + HandleHiddenServiceFrame( + ABSL_ATTRIBUTE_UNUSED const service::ProtocolFrame& frame) override { /// TODO: implement me - llarp::LogWarn("Got hidden service data on transit hop"); + LogWarn("Got hidden service data on transit hop"); return false; } bool - HandleGotIntroMessage(const llarp::dht::GotIntroMessage* msg); + HandleGotIntroMessage(const dht::GotIntroMessage& msg); bool - HandleDHTMessage(const llarp::dht::IMessage* msg, - AbstractRouter* r) override; + HandleDHTMessage(const dht::IMessage& msg, AbstractRouter* r) override; // handle data in upstream direction bool @@ -307,7 +301,7 @@ namespace llarp }; /// A path we made - struct Path : public IHopHandler, public llarp::routing::IMessageHandler + struct Path : public IHopHandler, public routing::IMessageHandler { using BuildResultHookFunc = std::function< void(Path*) >; using CheckForDeadFunc = std::function< bool(Path*, llarp_time_t) >; @@ -315,7 +309,7 @@ namespace llarp std::function< bool(Path*, const PathID_t&, uint64_t) >; using HopList = std::vector< PathHopConfig >; using DataHandlerFunc = - std::function< bool(Path*, const service::ProtocolFrame*) >; + std::function< bool(Path*, const service::ProtocolFrame&) >; using ExitUpdatedFunc = std::function< bool(Path*) >; using ExitClosedFunc = std::function< bool(Path*) >; using ExitTrafficHandlerFunc = @@ -327,7 +321,7 @@ namespace llarp PathSet* m_PathSet; - llarp::service::Introduction intro; + service::Introduction intro; llarp_time_t buildStarted; @@ -439,63 +433,59 @@ namespace llarp Tick(llarp_time_t now, AbstractRouter* r); bool - SendRoutingMessage(const llarp::routing::IMessage* msg, - llarp::AbstractRouter* r) override; + SendRoutingMessage(const routing::IMessage& msg, + AbstractRouter* r) override; bool - HandleObtainExitMessage(const llarp::routing::ObtainExitMessage* msg, + HandleObtainExitMessage(const routing::ObtainExitMessage& msg, AbstractRouter* r) override; bool - HandleUpdateExitVerifyMessage( - const llarp::routing::UpdateExitVerifyMessage* msg, - AbstractRouter* r) override; + HandleUpdateExitVerifyMessage(const routing::UpdateExitVerifyMessage& msg, + AbstractRouter* r) override; bool - HandleTransferTrafficMessage( - const llarp::routing::TransferTrafficMessage* msg, - AbstractRouter* r) override; + HandleTransferTrafficMessage(const routing::TransferTrafficMessage& msg, + AbstractRouter* r) override; bool - HandleUpdateExitMessage(const llarp::routing::UpdateExitMessage* msg, + HandleUpdateExitMessage(const routing::UpdateExitMessage& msg, AbstractRouter* r) override; bool - HandleCloseExitMessage(const llarp::routing::CloseExitMessage* msg, + HandleCloseExitMessage(const routing::CloseExitMessage& msg, AbstractRouter* r) override; bool - HandleGrantExitMessage(const llarp::routing::GrantExitMessage* msg, + HandleGrantExitMessage(const routing::GrantExitMessage& msg, AbstractRouter* r) override; bool - HandleRejectExitMessage(const llarp::routing::RejectExitMessage* msg, + HandleRejectExitMessage(const routing::RejectExitMessage& msg, AbstractRouter* r) override; bool - HandleDataDiscardMessage(const llarp::routing::DataDiscardMessage* msg, + HandleDataDiscardMessage(const routing::DataDiscardMessage& msg, AbstractRouter* r) override; bool - HandlePathConfirmMessage(const llarp::routing::PathConfirmMessage* msg, + HandlePathConfirmMessage(const routing::PathConfirmMessage& msg, AbstractRouter* r) override; bool - HandlePathLatencyMessage(const llarp::routing::PathLatencyMessage* msg, + HandlePathLatencyMessage(const routing::PathLatencyMessage& msg, AbstractRouter* r) override; bool - HandlePathTransferMessage(const llarp::routing::PathTransferMessage* msg, + HandlePathTransferMessage(const routing::PathTransferMessage& msg, AbstractRouter* r) override; bool - HandleHiddenServiceFrame( - const llarp::service::ProtocolFrame* frame) override; + HandleHiddenServiceFrame(const service::ProtocolFrame& frame) override; bool - HandleGotIntroMessage(const llarp::dht::GotIntroMessage* msg); + HandleGotIntroMessage(const dht::GotIntroMessage& msg); bool - HandleDHTMessage(const llarp::dht::IMessage* msg, - AbstractRouter* r) override; + HandleDHTMessage(const dht::IMessage& msg, AbstractRouter* r) override; bool HandleRoutingMessage(const llarp_buffer_t& buf, AbstractRouter* r); @@ -543,12 +533,10 @@ namespace llarp } bool - SendExitRequest(const llarp::routing::ObtainExitMessage* msg, - AbstractRouter* r); + SendExitRequest(const routing::ObtainExitMessage& msg, AbstractRouter* r); bool - SendExitClose(const llarp::routing::CloseExitMessage* msg, - AbstractRouter* r); + SendExitClose(const routing::CloseExitMessage& msg, AbstractRouter* r); private: /// call obtained exit hooks @@ -615,7 +603,7 @@ namespace llarp HasTransitHop(const TransitHopInfo& info); bool - HandleRelayCommit(const LR_CommitMessage* msg); + HandleRelayCommit(const LR_CommitMessage& msg); void PutTransitHop(std::shared_ptr< TransitHop > hop); @@ -646,10 +634,10 @@ namespace llarp HopIsUs(const RouterID& k) const; bool - HandleLRUM(const RelayUpstreamMessage* msg); + HandleLRUM(const RelayUpstreamMessage& msg); bool - HandleLRDM(const RelayDownstreamMessage* msg); + HandleLRDM(const RelayDownstreamMessage& msg); void AddOwnPath(PathSet* set, Path* p); @@ -684,13 +672,13 @@ namespace llarp llarp::Crypto* Crypto(); - llarp::Logic* + Logic* Logic(); AbstractRouter* Router(); - const llarp::SecretKey& + const SecretKey& EncryptionSecretKey(); const byte_t* diff --git a/llarp/path/pathset.hpp b/llarp/path/pathset.hpp index ac173cdb7..756e0dc9b 100644 --- a/llarp/path/pathset.hpp +++ b/llarp/path/pathset.hpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/llarp/path/transit_hop.cpp b/llarp/path/transit_hop.cpp index 9ac6921c3..82872c753 100644 --- a/llarp/path/transit_hop.cpp +++ b/llarp/path/transit_hop.cpp @@ -59,7 +59,7 @@ namespace llarp } bool - TransitHop::SendRoutingMessage(const llarp::routing::IMessage* msg, + TransitHop::SendRoutingMessage(const routing::IMessage& msg, AbstractRouter* r) { if(!IsEndpoint(r->pubkey())) @@ -67,7 +67,7 @@ namespace llarp std::array< byte_t, MAX_LINK_MSG_SIZE - 128 > tmp; llarp_buffer_t buf(tmp); - if(!msg->BEncode(&buf)) + if(!msg.BEncode(&buf)) { llarp::LogError("failed to encode routing message"); return false; @@ -126,7 +126,7 @@ namespace llarp } bool - TransitHop::HandleDHTMessage(const llarp::dht::IMessage* msg, + TransitHop::HandleDHTMessage(const llarp::dht::IMessage& msg, AbstractRouter* r) { return r->dht()->impl->RelayRequestForPath(info.rxID, msg); @@ -134,16 +134,16 @@ namespace llarp bool TransitHop::HandlePathLatencyMessage( - const llarp::routing::PathLatencyMessage* msg, AbstractRouter* r) + const llarp::routing::PathLatencyMessage& msg, AbstractRouter* r) { llarp::routing::PathLatencyMessage reply; - reply.L = msg->T; - return SendRoutingMessage(&reply, r); + reply.L = msg.T; + return SendRoutingMessage(reply, r); } bool TransitHop::HandlePathConfirmMessage( - __attribute__((unused)) const llarp::routing::PathConfirmMessage* msg, + __attribute__((unused)) const llarp::routing::PathConfirmMessage& msg, __attribute__((unused)) AbstractRouter* r) { llarp::LogWarn("unwarranted path confirm message on ", info); @@ -152,7 +152,7 @@ namespace llarp bool TransitHop::HandleDataDiscardMessage( - __attribute__((unused)) const llarp::routing::DataDiscardMessage* msg, + __attribute__((unused)) const llarp::routing::DataDiscardMessage& msg, __attribute__((unused)) AbstractRouter* r) { llarp::LogWarn("unwarranted path data discard message on ", info); @@ -161,55 +161,55 @@ namespace llarp bool TransitHop::HandleObtainExitMessage( - const llarp::routing::ObtainExitMessage* msg, AbstractRouter* r) + const llarp::routing::ObtainExitMessage& msg, AbstractRouter* r) { - if(msg->Verify(r->crypto()) - && r->exitContext().ObtainNewExit(msg->I, info.rxID, msg->E != 0)) + if(msg.Verify(r->crypto()) + && r->exitContext().ObtainNewExit(msg.I, info.rxID, msg.E != 0)) { llarp::routing::GrantExitMessage grant; grant.S = NextSeqNo(); - grant.T = msg->T; + grant.T = msg.T; if(!grant.Sign(r->crypto(), r->identity())) { llarp::LogError("Failed to sign grant exit message"); return false; } - return SendRoutingMessage(&grant, r); + return SendRoutingMessage(grant, r); } // TODO: exponential backoff // TODO: rejected policies llarp::routing::RejectExitMessage reject; reject.S = NextSeqNo(); - reject.T = msg->T; + reject.T = msg.T; if(!reject.Sign(r->crypto(), r->identity())) { llarp::LogError("Failed to sign reject exit message"); return false; } - return SendRoutingMessage(&reject, r); + return SendRoutingMessage(reject, r); } bool TransitHop::HandleCloseExitMessage( - const llarp::routing::CloseExitMessage* msg, AbstractRouter* r) + const llarp::routing::CloseExitMessage& msg, AbstractRouter* r) { - llarp::routing::DataDiscardMessage discard(info.rxID, msg->S); + llarp::routing::DataDiscardMessage discard(info.rxID, msg.S); auto ep = r->exitContext().FindEndpointForPath(info.rxID); - if(ep && msg->Verify(r->crypto(), ep->PubKey())) + if(ep && msg.Verify(r->crypto(), ep->PubKey())) { ep->Close(); // ep is now gone af llarp::routing::CloseExitMessage reply; reply.S = NextSeqNo(); if(reply.Sign(r->crypto(), r->identity())) - return SendRoutingMessage(&reply, r); + return SendRoutingMessage(reply, r); } - return SendRoutingMessage(&discard, r); + return SendRoutingMessage(discard, r); } bool TransitHop::HandleUpdateExitVerifyMessage( - const llarp::routing::UpdateExitVerifyMessage* msg, AbstractRouter* r) + const llarp::routing::UpdateExitVerifyMessage& msg, AbstractRouter* r) { (void)msg; (void)r; @@ -219,30 +219,30 @@ namespace llarp bool TransitHop::HandleUpdateExitMessage( - const llarp::routing::UpdateExitMessage* msg, AbstractRouter* r) + const llarp::routing::UpdateExitMessage& msg, AbstractRouter* r) { - auto ep = r->exitContext().FindEndpointForPath(msg->P); + auto ep = r->exitContext().FindEndpointForPath(msg.P); if(ep) { - if(!msg->Verify(r->crypto(), ep->PubKey())) + if(!msg.Verify(r->crypto(), ep->PubKey())) return false; if(ep->UpdateLocalPath(info.rxID)) { llarp::routing::UpdateExitVerifyMessage reply; - reply.T = msg->T; + reply.T = msg.T; reply.S = NextSeqNo(); - return SendRoutingMessage(&reply, r); + return SendRoutingMessage(reply, r); } } // on fail tell message was discarded - llarp::routing::DataDiscardMessage discard(info.rxID, msg->S); - return SendRoutingMessage(&discard, r); + llarp::routing::DataDiscardMessage discard(info.rxID, msg.S); + return SendRoutingMessage(discard, r); } bool TransitHop::HandleRejectExitMessage( - const llarp::routing::RejectExitMessage* msg, AbstractRouter* r) + const llarp::routing::RejectExitMessage& msg, AbstractRouter* r) { (void)msg; (void)r; @@ -252,7 +252,7 @@ namespace llarp bool TransitHop::HandleGrantExitMessage( - const llarp::routing::GrantExitMessage* msg, AbstractRouter* r) + const llarp::routing::GrantExitMessage& msg, AbstractRouter* r) { (void)msg; (void)r; @@ -262,13 +262,13 @@ namespace llarp bool TransitHop::HandleTransferTrafficMessage( - const llarp::routing::TransferTrafficMessage* msg, AbstractRouter* r) + const llarp::routing::TransferTrafficMessage& msg, AbstractRouter* r) { auto endpoint = r->exitContext().FindEndpointForPath(info.rxID); if(endpoint) { bool sent = true; - for(const auto& pkt : msg->X) + for(const auto& pkt : msg.X) { // check short packet buffer if(pkt.size() <= 8) @@ -283,35 +283,35 @@ namespace llarp else llarp::LogError("No exit endpoint on ", info); // discarded - llarp::routing::DataDiscardMessage discard(info.rxID, msg->S); - return SendRoutingMessage(&discard, r); + llarp::routing::DataDiscardMessage discard(info.rxID, msg.S); + return SendRoutingMessage(discard, r); } bool TransitHop::HandlePathTransferMessage( - const llarp::routing::PathTransferMessage* msg, AbstractRouter* r) + const llarp::routing::PathTransferMessage& msg, AbstractRouter* r) { - auto path = r->pathContext().GetPathForTransfer(msg->P); - llarp::routing::DataDiscardMessage discarded(msg->P, msg->S); - if(path == nullptr || msg->T.F != info.txID) + auto path = r->pathContext().GetPathForTransfer(msg.P); + llarp::routing::DataDiscardMessage discarded(msg.P, msg.S); + if(path == nullptr || msg.T.F != info.txID) { - return SendRoutingMessage(&discarded, r); + return SendRoutingMessage(discarded, r); } std::array< byte_t, service::MAX_PROTOCOL_MESSAGE_SIZE > tmp; llarp_buffer_t buf(tmp); - if(!msg->T.BEncode(&buf)) + if(!msg.T.BEncode(&buf)) { llarp::LogWarn(info, " failed to transfer data message, encode failed"); - return SendRoutingMessage(&discarded, r); + return SendRoutingMessage(discarded, r); } // rewind buf.sz = buf.cur - buf.base; buf.cur = buf.base; // send - if(path->HandleDownstream(buf, msg->Y, r)) + if(path->HandleDownstream(buf, msg.Y, r)) return true; - return SendRoutingMessage(&discarded, r); + return SendRoutingMessage(discarded, r); } } // namespace path diff --git a/llarp/routing/dht_message.cpp b/llarp/routing/dht_message.cpp index 7e0cc5eb3..08e07484b 100644 --- a/llarp/routing/dht_message.cpp +++ b/llarp/routing/dht_message.cpp @@ -58,7 +58,7 @@ namespace llarp { msg->From = us; msg->pathID = from; - if(!h->HandleDHTMessage(msg.get(), r)) + if(!h->HandleDHTMessage(*msg, r)) return false; } return true; diff --git a/llarp/routing/handler.hpp b/llarp/routing/handler.hpp index 354b10831..163da1540 100644 --- a/llarp/routing/handler.hpp +++ b/llarp/routing/handler.hpp @@ -33,53 +33,53 @@ namespace llarp struct IMessageHandler { virtual bool - HandleObtainExitMessage(const ObtainExitMessage *msg, + HandleObtainExitMessage(const ObtainExitMessage& msg, AbstractRouter *r) = 0; virtual bool - HandleGrantExitMessage(const GrantExitMessage *msg, + HandleGrantExitMessage(const GrantExitMessage& msg, AbstractRouter *r) = 0; virtual bool - HandleRejectExitMessage(const RejectExitMessage *msg, + HandleRejectExitMessage(const RejectExitMessage& msg, AbstractRouter *r) = 0; virtual bool - HandleTransferTrafficMessage(const TransferTrafficMessage *msg, + HandleTransferTrafficMessage(const TransferTrafficMessage& msg, AbstractRouter *r) = 0; virtual bool - HandleUpdateExitMessage(const UpdateExitMessage *msg, + HandleUpdateExitMessage(const UpdateExitMessage& msg, AbstractRouter *r) = 0; virtual bool - HandleUpdateExitVerifyMessage(const UpdateExitVerifyMessage *msg, + HandleUpdateExitVerifyMessage(const UpdateExitVerifyMessage& msg, AbstractRouter *r) = 0; virtual bool - HandleCloseExitMessage(const CloseExitMessage *msg, + HandleCloseExitMessage(const CloseExitMessage& msg, AbstractRouter *r) = 0; virtual bool - HandleDataDiscardMessage(const DataDiscardMessage *msg, + HandleDataDiscardMessage(const DataDiscardMessage& msg, AbstractRouter *r) = 0; virtual bool - HandlePathTransferMessage(const PathTransferMessage *msg, + HandlePathTransferMessage(const PathTransferMessage& msg, AbstractRouter *r) = 0; virtual bool - HandleHiddenServiceFrame(const service::ProtocolFrame *msg) = 0; + HandleHiddenServiceFrame(const service::ProtocolFrame& msg) = 0; virtual bool - HandlePathConfirmMessage(const PathConfirmMessage *msg, + HandlePathConfirmMessage(const PathConfirmMessage& msg, AbstractRouter *r) = 0; virtual bool - HandlePathLatencyMessage(const PathLatencyMessage *msg, + HandlePathLatencyMessage(const PathLatencyMessage& msg, AbstractRouter *r) = 0; virtual bool - HandleDHTMessage(const dht::IMessage *msg, AbstractRouter *r) = 0; + HandleDHTMessage(const dht::IMessage& msg, AbstractRouter *r) = 0; }; } // namespace routing } // namespace llarp diff --git a/llarp/routing/path_confirm.cpp b/llarp/routing/path_confirm.cpp index dec6ff447..9a3a36380 100644 --- a/llarp/routing/path_confirm.cpp +++ b/llarp/routing/path_confirm.cpp @@ -55,7 +55,7 @@ namespace llarp PathConfirmMessage::HandleMessage(IMessageHandler* h, AbstractRouter* r) const { - return h && h->HandlePathConfirmMessage(this, r); + return h && h->HandlePathConfirmMessage(*this, r); } } // namespace routing diff --git a/llarp/routing/path_latency.cpp b/llarp/routing/path_latency.cpp index e3ecbeabd..4ec8f7e8a 100644 --- a/llarp/routing/path_latency.cpp +++ b/llarp/routing/path_latency.cpp @@ -49,7 +49,7 @@ namespace llarp PathLatencyMessage::HandleMessage(IMessageHandler* h, AbstractRouter* r) const { - return h && h->HandlePathLatencyMessage(this, r); + return h && h->HandlePathLatencyMessage(*this, r); } } // namespace routing diff --git a/llarp/routing/path_transfer.cpp b/llarp/routing/path_transfer.cpp index 6e360f533..6d0c6447c 100644 --- a/llarp/routing/path_transfer.cpp +++ b/llarp/routing/path_transfer.cpp @@ -61,7 +61,7 @@ namespace llarp PathTransferMessage::HandleMessage(IMessageHandler* h, AbstractRouter* r) const { - return h->HandlePathTransferMessage(this, r); + return h->HandlePathTransferMessage(*this, r); } } // namespace routing diff --git a/llarp/service/IntroSet.hpp b/llarp/service/IntroSet.hpp deleted file mode 100644 index 3c868a9f1..000000000 --- a/llarp/service/IntroSet.hpp +++ /dev/null @@ -1,150 +0,0 @@ -#ifndef LLARP_SERVICE_INTROSET_HPP -#define LLARP_SERVICE_INTROSET_HPP - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -namespace llarp -{ - struct Crypto; - - namespace service - { - constexpr std::size_t MAX_INTROSET_SIZE = 4096; - // 10 seconds clock skew permitted for introset expiration - constexpr llarp_time_t MAX_INTROSET_TIME_DELTA = (10 * 1000); - struct IntroSet final : public llarp::IBEncodeMessage - { - util::StatusObject - ExtractStatus() const; - - ServiceInfo A; - std::vector< Introduction > I; - PQPubKey K; - Tag topic; - llarp_time_t T = 0; - llarp::PoW* W = nullptr; - llarp::Signature Z; - - IntroSet() = default; - - IntroSet(IntroSet&& other) : IBEncodeMessage(other.version) - { - A = std::move(other.A); - I = std::move(other.I); - K = std::move(other.K); - T = std::move(other.T); - version = std::move(other.version); - topic = std::move(other.topic); - W = std::move(other.W); - Z = std::move(other.Z); - } - - IntroSet(const IntroSet& other) : IBEncodeMessage(other.version) - { - A = other.A; - I = other.I; - K = other.K; - T = other.T; - version = other.version; - topic = other.topic; - if(other.W) - W = new llarp::PoW(*other.W); - Z = other.Z; - } - - ~IntroSet(); - - IntroSet& - operator=(const IntroSet& other) - { - I.clear(); - A = other.A; - I = other.I; - K = other.K; - T = other.T; - version = other.version; - topic = other.topic; - if(W) - { - delete W; - W = nullptr; - } - if(other.W) - W = new llarp::PoW(*other.W); - Z = other.Z; - return *this; - } - - bool - operator<(const IntroSet& other) const - { - return A < other.A; - } - - bool - operator==(const IntroSet& other) const - { - return A == other.A && I == other.I && K == other.K && T == other.T - && version == other.version && topic == other.topic && W == other.W - && Z == other.Z; - } - - bool - operator!=(const IntroSet& other) const - { - return !(*this == other); - } - - bool - OtherIsNewer(const IntroSet& other) const - { - return T < other.T; - } - - std::ostream& - print(std::ostream& stream, int level, int spaces) const; - - llarp_time_t - GetNewestIntroExpiration() const; - - bool - HasExpiredIntros(llarp_time_t now) const; - - bool - IsExpired(llarp_time_t now) const; - - bool - BEncode(llarp_buffer_t* buf) const override; - - bool - DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* buf) override; - - bool - Verify(llarp::Crypto* crypto, llarp_time_t now) const; - }; - - inline std::ostream& - operator<<(std::ostream& out, const IntroSet& i) - { - return i.print(out, -1, -1); - } - - using IntroSetLookupHandler = - std::function< void(const std::vector< IntroSet >&) >; - - } // namespace service -} // namespace llarp - -#endif diff --git a/llarp/service/async_key_exchange.hpp b/llarp/service/async_key_exchange.hpp index e70bf4eed..e2dede04c 100644 --- a/llarp/service/async_key_exchange.hpp +++ b/llarp/service/async_key_exchange.hpp @@ -2,7 +2,7 @@ #define LLARP_SERVICE_ASYNC_KEY_EXCHANGE_HPP #include -#include +#include #include namespace llarp diff --git a/llarp/service/config.cpp b/llarp/service/config.cpp index e8f39db26..84e3a6585 100644 --- a/llarp/service/config.cpp +++ b/llarp/service/config.cpp @@ -9,12 +9,12 @@ namespace llarp bool Config::Load(const std::string& fname) { - llarp::ConfigParser parser; + ConfigParser parser; if(!parser.LoadFile(fname.c_str())) return false; - parser.IterAll([&](const llarp::ConfigParser::String_t& name, - const llarp::ConfigParser::Section_t& section) { - llarp::service::Config::section_t values; + parser.IterAll([&](const ConfigParser::String_t& name, + const ConfigParser::Section_t& section) { + Config::section_t values; values.first.assign(name.begin(), name.end()); for(const auto& item : section) values.second.emplace_back(string_view_string(item.first), diff --git a/llarp/service/context.cpp b/llarp/service/context.cpp index a00dd487c..b52b9c59f 100644 --- a/llarp/service/context.cpp +++ b/llarp/service/context.cpp @@ -118,12 +118,12 @@ namespace llarp return m_Endpoints.size() ? true : false; } - llarp::service::Endpoint * + service::Endpoint * Context::getFirstEndpoint() { if(!m_Endpoints.size()) { - llarp::LogError("No endpoints found"); + LogError("No endpoints found"); return nullptr; } auto itr = m_Endpoints.begin(); @@ -137,11 +137,11 @@ namespace llarp { if(!m_Endpoints.size()) { - llarp::LogError("No endpoints found"); + LogError("No endpoints found"); return false; } i.index = 0; - // llarp::util::Lock lock(access); + // util::Lock lock(access); auto itr = m_Endpoints.begin(); while(itr != m_Endpoints.end()) { @@ -155,34 +155,34 @@ namespace llarp return true; } - llarp::handlers::TunEndpoint * + handlers::TunEndpoint * Context::getFirstTun() { - llarp::service::Endpoint *endpointer = this->getFirstEndpoint(); + service::Endpoint *endpointer = this->getFirstEndpoint(); if(!endpointer) { return nullptr; } - llarp::handlers::TunEndpoint *tunEndpoint = - static_cast< llarp::handlers::TunEndpoint * >(endpointer); + handlers::TunEndpoint *tunEndpoint = + static_cast< handlers::TunEndpoint * >(endpointer); return tunEndpoint; } llarp_tun_io * Context::getRange() { - llarp::handlers::TunEndpoint *tunEndpoint = this->getFirstTun(); + handlers::TunEndpoint *tunEndpoint = this->getFirstTun(); if(!tunEndpoint) { - llarp::LogError("No tunnel endpoint found"); + LogError("No tunnel endpoint found"); return nullptr; } return &tunEndpoint->tunif; } bool - Context::FindBestAddressFor(const llarp::AlignedBuffer< 32 > &addr, - bool isSNode, huint32_t &ip) + Context::FindBestAddressFor(const AlignedBuffer< 32 > &addr, bool isSNode, + huint32_t &ip) { auto itr = m_Endpoints.begin(); while(itr != m_Endpoints.end()) @@ -204,12 +204,12 @@ namespace llarp } bool - Context::Prefetch(const llarp::service::Address &addr) + Context::Prefetch(const service::Address &addr) { - llarp::handlers::TunEndpoint *tunEndpoint = this->getFirstTun(); + handlers::TunEndpoint *tunEndpoint = this->getFirstTun(); if(!tunEndpoint) { - llarp::LogError("No tunnel endpoint found"); + LogError("No tunnel endpoint found"); return false; } // HiddenServiceAddresslookup *lookup = new @@ -227,11 +227,11 @@ namespace llarp { Context::mapAddressAll_context *context = (Context::mapAddressAll_context *)endpointCfg->user; - llarp::handlers::TunEndpoint *tunEndpoint = - (llarp::handlers::TunEndpoint *)endpointCfg->endpoint; + handlers::TunEndpoint *tunEndpoint = + (handlers::TunEndpoint *)endpointCfg->endpoint; if(!tunEndpoint) { - llarp::LogError("No tunnel endpoint found"); + LogError("No tunnel endpoint found"); return true; // still continue } return tunEndpoint->MapAddress( @@ -239,8 +239,8 @@ namespace llarp } bool - Context::MapAddressAll(const llarp::service::Address &addr, - llarp::Addr &localPrivateIpAddr) + Context::MapAddressAll(const service::Address &addr, + Addr &localPrivateIpAddr) { struct Context::mapAddressAll_context context; context.serviceAddr = addr; @@ -278,10 +278,10 @@ namespace llarp { if(!itr->second->Start()) { - llarp::LogError(itr->first, " failed to start"); + LogError(itr->first, " failed to start"); return false; } - llarp::LogInfo(itr->first, " started"); + LogInfo(itr->first, " started"); ++itr; } return true; @@ -294,8 +294,8 @@ namespace llarp auto itr = m_Endpoints.find(conf.first); if(itr != m_Endpoints.end()) { - llarp::LogError("cannot add hidden service with duplicate name: ", - conf.first); + LogError("cannot add hidden service with duplicate name: ", + conf.first); return false; } } @@ -309,22 +309,23 @@ namespace llarp if(option.first == "keyfile") keyfile = option.second; } - std::unique_ptr< llarp::service::Endpoint > service; - static std::map< std::string, - std::function< llarp::service::Endpoint *( - const std::string &, AbstractRouter *, - llarp::service::Context *) > > + std::unique_ptr< service::Endpoint > service; + + static std::map< + std::string, + std::function< std::unique_ptr< service::Endpoint >( + const std::string &, AbstractRouter *, service::Context *) > > endpointConstructors = { {"tun", [](const std::string &nick, AbstractRouter *r, - llarp::service::Context *c) -> llarp::service::Endpoint * { - return new llarp::handlers::TunEndpoint(nick, r, c); + service::Context *c) -> std::unique_ptr< service::Endpoint > { + return std::make_unique< handlers::TunEndpoint >(nick, r, c); }}, {"null", [](const std::string &nick, AbstractRouter *r, - llarp::service::Context *c) -> llarp::service::Endpoint * { - return new llarp::handlers::NullEndpoint(nick, r, c); + service::Context *c) -> std::unique_ptr< service::Endpoint > { + return std::make_unique< handlers::NullEndpoint >(nick, r, c); }}}; { @@ -332,12 +333,12 @@ namespace llarp auto itr = endpointConstructors.find(endpointType); if(itr == endpointConstructors.end()) { - llarp::LogError("no such endpoint type: ", endpointType); + LogError("no such endpoint type: ", endpointType); return false; } // construct - service.reset(itr->second(conf.first, m_Router, this)); + service = itr->second(conf.first, m_Router, this); // if ephemeral, then we need to regen key // if privkey file, then set it and load it @@ -346,7 +347,7 @@ namespace llarp service->SetOption("keyfile", keyfile); // load keyfile, so we have the correct name for logging } - llarp::LogInfo("Establishing endpoint identity"); + LogInfo("Establishing endpoint identity"); service->LoadKeyFile(); // only start endpoint not tun // now Name() will be correct } @@ -359,8 +360,8 @@ namespace llarp auto &v = option.second; if(!service->SetOption(k, v)) { - llarp::LogError("failed to set ", k, "=", v, - " for hidden service endpoint ", conf.first); + LogError("failed to set ", k, "=", v, " for hidden service endpoint ", + conf.first); return false; } } @@ -369,17 +370,16 @@ namespace llarp // start if(service->Start()) { - llarp::LogInfo("autostarting hidden service endpoint ", - service->Name()); + LogInfo("autostarting hidden service endpoint ", service->Name()); m_Endpoints.emplace(conf.first, std::move(service)); return true; } - llarp::LogError("failed to start hidden service endpoint ", conf.first); + LogError("failed to start hidden service endpoint ", conf.first); return false; } else { - llarp::LogInfo("added hidden service endpoint ", service->Name()); + LogInfo("added hidden service endpoint ", service->Name()); m_Endpoints.emplace(conf.first, std::move(service)); return true; } diff --git a/llarp/service/context.hpp b/llarp/service/context.hpp index ce7b30cf8..1de3d71db 100644 --- a/llarp/service/context.hpp +++ b/llarp/service/context.hpp @@ -15,7 +15,7 @@ namespace llarp /// holds all the hidden service endpoints we own struct Context { - Context(AbstractRouter *r); + explicit Context(AbstractRouter *r); ~Context(); void @@ -32,15 +32,15 @@ namespace llarp hasEndpoints(); /// DRY refactor - llarp::service::Endpoint * + service::Endpoint * getFirstEndpoint(); bool - FindBestAddressFor(const llarp::AlignedBuffer< 32 > &addr, bool isSNode, + FindBestAddressFor(const AlignedBuffer< 32 > &addr, bool isSNode, huint32_t &); /// DRY refactor - llarp::handlers::TunEndpoint * + handlers::TunEndpoint * getFirstTun(); /// punch a hole to get ip range from first tun endpoint @@ -49,14 +49,14 @@ namespace llarp struct mapAddressAll_context { - llarp::service::Address serviceAddr; - llarp::Addr localPrivateIpAddr; + service::Address serviceAddr; + Addr localPrivateIpAddr; }; struct endpoint_iter { void *user; - llarp::service::Endpoint *endpoint; + service::Endpoint *endpoint; size_t index; bool (*visit)(struct endpoint_iter *); }; @@ -72,11 +72,10 @@ namespace llarp /// hint at possible path usage and trigger building early bool - Prefetch(const llarp::service::Address &addr); + Prefetch(const service::Address &addr); bool - MapAddressAll(const llarp::service::Address &addr, - llarp::Addr &localPrivateIpAddr); + MapAddressAll(const service::Address &addr, Addr &localPrivateIpAddr); /// add default endpoint with options bool diff --git a/llarp/service/endpoint.cpp b/llarp/service/endpoint.cpp index 77b5db40f..8f09491da 100644 --- a/llarp/service/endpoint.cpp +++ b/llarp/service/endpoint.cpp @@ -670,11 +670,12 @@ namespace llarp { } - routing::IMessage* + std::unique_ptr< routing::IMessage > BuildRequestMessage() { - routing::DHTMessage* msg = new routing::DHTMessage(); - msg->M.emplace_back(new dht::PublishIntroMessage(m_IntroSet, txid, 1)); + auto msg = std::make_unique< routing::DHTMessage >(); + msg->M.emplace_back( + std::make_unique< dht::PublishIntroMessage >(m_IntroSet, txid, 1)); return msg; } @@ -795,8 +796,8 @@ namespace llarp return; } - OutboundContext* ctx = new OutboundContext(introset, this); - m_RemoteSessions.emplace(addr, std::unique_ptr< OutboundContext >(ctx)); + auto it = m_RemoteSessions.emplace( + addr, std::make_unique< OutboundContext >(introset, this)); LogInfo("Created New outbound context for ", addr.ToString()); // inform pending @@ -804,7 +805,7 @@ namespace llarp auto itr = range.first; if(itr != range.second) { - itr->second(addr, ctx); + itr->second(addr, it->second.get()); ++itr; } m_PendingServiceLookups.erase(addr); @@ -851,9 +852,10 @@ namespace llarp auto path = GetEstablishedPathClosestTo(router); routing::DHTMessage msg; auto txid = GenTXID(); - msg.M.emplace_back(new dht::FindRouterMessage(txid, router)); + msg.M.emplace_back( + std::make_unique< dht::FindRouterMessage >(txid, router)); - if(path && path->SendRoutingMessage(&msg, m_Router)) + if(path && path->SendRoutingMessage(msg, m_Router)) { LogInfo(Name(), " looking up ", router); m_PendingRouters.emplace(router, RouterLookupJob(this)); @@ -868,15 +870,11 @@ namespace llarp void Endpoint::HandlePathBuilt(path::Path* p) { - p->SetDataHandler(std::bind(&Endpoint::HandleHiddenServiceFrame, this, - std::placeholders::_1, - std::placeholders::_2)); - p->SetDropHandler(std::bind(&Endpoint::HandleDataDrop, this, - std::placeholders::_1, std::placeholders::_2, - std::placeholders::_3)); - p->SetDeadChecker(std::bind(&Endpoint::CheckPathIsDead, this, - std::placeholders::_1, - std::placeholders::_2)); + using namespace std::placeholders; + p->SetDataHandler( + std::bind(&Endpoint::HandleHiddenServiceFrame, this, _1, _2)); + p->SetDropHandler(std::bind(&Endpoint::HandleDataDrop, this, _1, _2, _3)); + p->SetDeadChecker(std::bind(&Endpoint::CheckPathIsDead, this, _1, _2)); path::Builder::HandlePathBuilt(p); } @@ -949,34 +947,35 @@ namespace llarp bool Endpoint::HandleHiddenServiceFrame(path::Path* p, - const ProtocolFrame* frame) + const ProtocolFrame& frame) { - if(frame->R) + if(frame.R) { // handle discard ServiceInfo si; - if(!GetSenderFor(frame->T, si)) + if(!GetSenderFor(frame.T, si)) return false; // verify source if(!frame->Verify(GetCrypto(), si)) return false; // remove convotag it doesn't exist - LogWarn("remove convotag T=", frame->T); - RemoveConvoTag(frame->T); + LogWarn("remove convotag T=", frame.T); + RemoveConvoTag(frame.T); return true; } - if(!frame->AsyncDecryptAndVerify(EndpointLogic(), GetCrypto(), p, + if(!frame.AsyncDecryptAndVerify(EndpointLogic(), GetCrypto(), p, Worker(), m_Identity, m_DataHandler)) + { // send discard ProtocolFrame f; f.R = 1; - f.T = frame->T; + f.T = frame.T; f.F = p->intro.pathID; if(!f.Sign(GetCrypto(), m_Identity)) return false; - const routing::PathTransferMessage d(f, frame->F); - return p->SendRoutingMessage(&d, router); + const routing::PathTransferMessage d(f, frame.F); + return p->SendRoutingMessage(d, router); } return true; } @@ -1051,11 +1050,10 @@ namespace llarp return false; } + using namespace std::placeholders; HiddenServiceAddressLookup* job = new HiddenServiceAddressLookup( - this, - std::bind(&Endpoint::OnLookup, this, std::placeholders::_1, - std::placeholders::_2, std::placeholders::_3), - remote, GenTXID()); + this, std::bind(&Endpoint::OnLookup, this, _1, _2, _3), remote, + GenTXID()); LogInfo("doing lookup for ", remote, " via ", path->Endpoint()); if(job->SendRequestViaPath(path, Router())) { @@ -1069,6 +1067,7 @@ namespace llarp void Endpoint::EnsurePathToSNode(const RouterID& snode, SNodeEnsureHook h) { + using namespace std::placeholders; if(m_SNodeSessions.count(snode) == 0) { auto themIP = ObtainIPForAddr(snode, true); @@ -1076,8 +1075,7 @@ namespace llarp snode, std::make_unique< exit::SNodeSession >( snode, - std::bind(&Endpoint::HandleWriteIPPacket, this, - std::placeholders::_1, + std::bind(&Endpoint::HandleWriteIPPacket, this, _1, [themIP]() -> huint32_t { return themIP; }), m_Router, 2, numHops)); } @@ -1088,7 +1086,7 @@ namespace llarp if(itr->second->IsReady()) h(snode, itr->second.get()); else - itr->second->AddReadyHook(std::bind(h, snode, std::placeholders::_1)); + itr->second->AddReadyHook(std::bind(h, snode, _1)); ++itr; } } @@ -1176,7 +1174,7 @@ namespace llarp return false; } LogDebug(Name(), " send ", data.sz, " via ", remoteIntro.router); - return p->SendRoutingMessage(&transfer, Router()); + return p->SendRoutingMessage(transfer, Router()); } } } diff --git a/llarp/service/endpoint.hpp b/llarp/service/endpoint.hpp index 769841611..1abeab3cb 100644 --- a/llarp/service/endpoint.hpp +++ b/llarp/service/endpoint.hpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include #include #include @@ -138,7 +138,7 @@ namespace llarp bool HandleHiddenServiceFrame(path::Path* p, - const service::ProtocolFrame* msg); + const service::ProtocolFrame& msg); /// return true if we have an established path to a hidden service bool diff --git a/llarp/service/handler.hpp b/llarp/service/handler.hpp index 5b2f9fc74..85c661a8f 100644 --- a/llarp/service/handler.hpp +++ b/llarp/service/handler.hpp @@ -3,14 +3,14 @@ #include #include -#include +#include #include namespace llarp { namespace service { - using ConvoTag = llarp::AlignedBuffer< 16 >; + using ConvoTag = AlignedBuffer< 16 >; struct ProtocolMessage; struct IDataHandler diff --git a/llarp/service/hidden_service_address_lookup.cpp b/llarp/service/hidden_service_address_lookup.cpp index cff3ddb12..d3b1c6f5f 100644 --- a/llarp/service/hidden_service_address_lookup.cpp +++ b/llarp/service/hidden_service_address_lookup.cpp @@ -33,11 +33,12 @@ namespace llarp return handle(remote, nullptr, endpoint); } - routing::IMessage* + std::unique_ptr< routing::IMessage > HiddenServiceAddressLookup::BuildRequestMessage() { - routing::DHTMessage* msg = new routing::DHTMessage(); - msg->M.emplace_back(new dht::FindIntroMessage(txid, remote, 0)); + auto msg = std::make_unique< routing::DHTMessage >(); + msg->M.emplace_back( + std::make_unique< dht::FindIntroMessage >(txid, remote, 0)); return msg; } diff --git a/llarp/service/hidden_service_address_lookup.hpp b/llarp/service/hidden_service_address_lookup.hpp index 04d250360..a7077b93d 100644 --- a/llarp/service/hidden_service_address_lookup.hpp +++ b/llarp/service/hidden_service_address_lookup.hpp @@ -2,7 +2,7 @@ #define LLARP_SERVICE_HIDDEN_SERVICE_ADDRESS_LOOKUP_HPP #include -#include +#include #include namespace llarp @@ -27,7 +27,7 @@ namespace llarp bool HandleResponse(const std::set< IntroSet >& results); - routing::IMessage* + std::unique_ptr< routing::IMessage > BuildRequestMessage(); }; } // namespace service diff --git a/llarp/service/Identity.cpp b/llarp/service/identity.cpp similarity index 87% rename from llarp/service/Identity.cpp rename to llarp/service/identity.cpp index b523e078c..878134ff3 100644 --- a/llarp/service/Identity.cpp +++ b/llarp/service/identity.cpp @@ -1,4 +1,4 @@ -#include +#include #include @@ -57,12 +57,11 @@ namespace llarp } void - Identity::RegenerateKeys(llarp::Crypto* crypto) + Identity::RegenerateKeys(Crypto* crypto) { crypto->encryption_keygen(enckey); crypto->identity_keygen(signkey); - pub.Update(llarp::seckey_topublic(enckey), - llarp::seckey_topublic(signkey)); + pub.Update(seckey_topublic(enckey), seckey_topublic(signkey)); crypto->pqe_keygen(pq); } @@ -81,7 +80,7 @@ namespace llarp } bool - Identity::EnsureKeys(const std::string& fname, llarp::Crypto* c) + Identity::EnsureKeys(const std::string& fname, Crypto* c) { std::array< byte_t, 4096 > tmp; llarp_buffer_t buf(tmp); @@ -91,7 +90,7 @@ namespace llarp { if(ec) { - llarp::LogError(ec); + LogError(ec); return false; } // regen and encode @@ -125,14 +124,12 @@ namespace llarp if(!vanity.IsZero()) van = vanity; // update pubkeys - pub.Update(llarp::seckey_topublic(enckey), - llarp::seckey_topublic(signkey), van); + pub.Update(seckey_topublic(enckey), seckey_topublic(signkey), van); return true; } bool - Identity::SignIntroSet(IntroSet& i, llarp::Crypto* crypto, - llarp_time_t now) const + Identity::SignIntroSet(IntroSet& i, Crypto* crypto, llarp_time_t now) const { if(i.I.size() == 0) return false; diff --git a/llarp/service/Identity.hpp b/llarp/service/identity.hpp similarity index 59% rename from llarp/service/Identity.hpp rename to llarp/service/identity.hpp index bc1cf7830..481f2c6e2 100644 --- a/llarp/service/Identity.hpp +++ b/llarp/service/identity.hpp @@ -2,9 +2,9 @@ #define LLARP_SERVICE_IDENTITY_HPP #include -#include -#include -#include +#include +#include +#include #include namespace llarp @@ -14,11 +14,11 @@ namespace llarp namespace service { // private keys - struct Identity final : public llarp::IBEncodeMessage + struct Identity final : public IBEncodeMessage { - llarp::SecretKey enckey; - llarp::SecretKey signkey; - llarp::PQKeyPair pq; + SecretKey enckey; + SecretKey signkey; + PQKeyPair pq; uint64_t version = 0; VanityNonce vanity; @@ -29,7 +29,7 @@ namespace llarp // regenerate secret keys void - RegenerateKeys(llarp::Crypto* c); + RegenerateKeys(Crypto* c); // load from file bool @@ -39,20 +39,20 @@ namespace llarp BEncode(llarp_buffer_t* buf) const override; bool - EnsureKeys(const std::string& fpath, llarp::Crypto* c); + EnsureKeys(const std::string& fpath, Crypto* c); bool - KeyExchange(llarp::path_dh_func dh, SharedSecret& sharedkey, + KeyExchange(path_dh_func dh, SharedSecret& sharedkey, const ServiceInfo& other, const KeyExchangeNonce& N) const; bool DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* buf) override; bool - SignIntroSet(IntroSet& i, llarp::Crypto* c, llarp_time_t now) const; + SignIntroSet(IntroSet& i, Crypto* c, llarp_time_t now) const; bool - Sign(llarp::Crypto*, Signature& sig, const llarp_buffer_t& buf) const; + Sign(Crypto*, Signature& sig, const llarp_buffer_t& buf) const; }; } // namespace service } // namespace llarp diff --git a/llarp/service/info.cpp b/llarp/service/info.cpp index 8005a02c4..4a74dd126 100644 --- a/llarp/service/info.cpp +++ b/llarp/service/info.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -13,7 +13,7 @@ namespace llarp namespace service { bool - ServiceInfo::Verify(llarp::Crypto* crypto, const llarp_buffer_t& payload, + ServiceInfo::Verify(Crypto* crypto, const llarp_buffer_t& payload, const Signature& sig) const { return crypto->verify(signkey, payload, sig); diff --git a/llarp/service/Info.hpp b/llarp/service/info.hpp similarity index 93% rename from llarp/service/Info.hpp rename to llarp/service/info.hpp index bcac130d0..b88bb6da4 100644 --- a/llarp/service/Info.hpp +++ b/llarp/service/info.hpp @@ -2,7 +2,8 @@ #define LLARP_SERVICE_INFO_HPP #include -#include +#include +#include #include #include @@ -13,11 +14,11 @@ namespace llarp namespace service { - struct ServiceInfo final : public llarp::IBEncodeMessage + struct ServiceInfo final : public IBEncodeMessage { private: - llarp::PubKey enckey; - llarp::PubKey signkey; + PubKey enckey; + PubKey signkey; public: VanityNonce vanity; @@ -52,7 +53,7 @@ namespace llarp } bool - Verify(llarp::Crypto* crypto, const llarp_buffer_t& payload, + Verify(Crypto* crypto, const llarp_buffer_t& payload, const Signature& sig) const; const PubKey& diff --git a/llarp/service/Intro.cpp b/llarp/service/intro.cpp similarity index 98% rename from llarp/service/Intro.cpp rename to llarp/service/intro.cpp index 770f035da..c15c8e342 100644 --- a/llarp/service/Intro.cpp +++ b/llarp/service/intro.cpp @@ -1,4 +1,4 @@ -#include +#include namespace llarp { diff --git a/llarp/service/Intro.hpp b/llarp/service/intro.hpp similarity index 100% rename from llarp/service/Intro.hpp rename to llarp/service/intro.hpp diff --git a/llarp/service/IntroSet.cpp b/llarp/service/intro_set.cpp similarity index 91% rename from llarp/service/IntroSet.cpp rename to llarp/service/intro_set.cpp index d0c59093c..7955d775d 100644 --- a/llarp/service/IntroSet.cpp +++ b/llarp/service/intro_set.cpp @@ -1,4 +1,4 @@ -#include +#include #include @@ -6,12 +6,6 @@ namespace llarp { namespace service { - IntroSet::~IntroSet() - { - if(W) - delete W; - } - util::StatusObject IntroSet::ExtractStatus() const { @@ -49,9 +43,7 @@ namespace llarp if(key == "w") { - if(W) - delete W; - W = new PoW(); + W = absl::make_optional< PoW >(); return W->BDecode(buf); } @@ -122,7 +114,7 @@ namespace llarp } bool - IntroSet::Verify(llarp::Crypto* crypto, llarp_time_t now) const + IntroSet::Verify(Crypto* crypto, llarp_time_t now) const { std::array< byte_t, MAX_INTROSET_SIZE > tmp; llarp_buffer_t buf(tmp); @@ -156,17 +148,19 @@ namespace llarp { if(W && intro.expiresAt - W->extendedLifetime > path::default_lifetime) + { return false; - else if(W == nullptr) + } + else if(!W.has_value()) { - llarp::LogWarn("intro has too high expire time"); + LogWarn("intro has too high expire time"); return false; } } } if(IsExpired(now)) { - llarp::LogWarn("introset expired: ", *this); + LogWarn("introset expired: ", *this); return false; } return true; @@ -201,7 +195,14 @@ namespace llarp } printer.printAttribute("T", T); - printer.printAttribute("W", W); + if(W) + { + printer.printAttribute("W", W.value()); + } + else + { + printer.printAttribute("W", "NULL"); + } printer.printAttribute("V", version); printer.printAttribute("Z", Z); diff --git a/llarp/service/intro_set.hpp b/llarp/service/intro_set.hpp new file mode 100644 index 000000000..e8a680850 --- /dev/null +++ b/llarp/service/intro_set.hpp @@ -0,0 +1,102 @@ +#ifndef LLARP_SERVICE_INTRO_SET_HPP +#define LLARP_SERVICE_INTRO_SET_HPP + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +namespace llarp +{ + struct Crypto; + + namespace service + { + constexpr std::size_t MAX_INTROSET_SIZE = 4096; + // 10 seconds clock skew permitted for introset expiration + constexpr llarp_time_t MAX_INTROSET_TIME_DELTA = (10 * 1000); + struct IntroSet final : public IBEncodeMessage + { + ServiceInfo A; + std::vector< Introduction > I; + PQPubKey K; + Tag topic; + llarp_time_t T = 0; + absl::optional< PoW > W; + Signature Z; + + bool + OtherIsNewer(const IntroSet& other) const + { + return T < other.T; + } + + std::ostream& + print(std::ostream& stream, int level, int spaces) const; + + llarp_time_t + GetNewestIntroExpiration() const; + + bool + HasExpiredIntros(llarp_time_t now) const; + + bool + IsExpired(llarp_time_t now) const; + + bool + BEncode(llarp_buffer_t* buf) const override; + + bool + DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* buf) override; + + bool + Verify(Crypto* crypto, llarp_time_t now) const; + + util::StatusObject + ExtractStatus() const; + }; + + inline bool + operator<(const IntroSet& lhs, const IntroSet& rhs) + { + return lhs.A < rhs.A; + } + + inline bool + operator==(const IntroSet& lhs, const IntroSet& rhs) + { + return std::tie(lhs.A, lhs.I, lhs.K, lhs.T, lhs.version, lhs.topic, lhs.W, + lhs.Z) + == std::tie(rhs.A, rhs.I, rhs.K, rhs.T, rhs.version, rhs.topic, rhs.W, + rhs.Z); + } + + inline bool + operator!=(const IntroSet& lhs, const IntroSet& rhs) + { + return !(lhs == rhs); + } + + inline std::ostream& + operator<<(std::ostream& out, const IntroSet& i) + { + return i.print(out, -1, -1); + } + + using IntroSetLookupHandler = + std::function< void(const std::vector< IntroSet >&) >; + + } // namespace service +} // namespace llarp + +#endif diff --git a/llarp/service/lookup.cpp b/llarp/service/lookup.cpp index e724df3b4..22445c68f 100644 --- a/llarp/service/lookup.cpp +++ b/llarp/service/lookup.cpp @@ -23,9 +23,8 @@ namespace llarp auto msg = BuildRequestMessage(); if(!msg) return false; - auto result = path->SendRoutingMessage(msg, r); + auto result = path->SendRoutingMessage(*msg, r); endpoint = path->Endpoint(); - delete msg; return result; } } // namespace service diff --git a/llarp/service/lookup.hpp b/llarp/service/lookup.hpp index baf2703c5..e0738fc21 100644 --- a/llarp/service/lookup.hpp +++ b/llarp/service/lookup.hpp @@ -2,7 +2,7 @@ #define LLARP_SERVICE_LOOKUP_HPP #include -#include +#include #include @@ -43,12 +43,12 @@ namespace llarp } /// build request message for service lookup - virtual llarp::routing::IMessage* + virtual std::unique_ptr< routing::IMessage > BuildRequestMessage() = 0; - /// build a new requset message and send it via a path + /// build a new request message and send it via a path bool - SendRequestViaPath(llarp::path::Path* p, AbstractRouter* r); + SendRequestViaPath(path::Path* p, AbstractRouter* r); ILookupHolder* parent; uint64_t txid; @@ -58,7 +58,7 @@ namespace llarp util::StatusObject ExtractStatus() const { - auto now = llarp::time_now_ms(); + auto now = time_now_ms(); util::StatusObject obj{{"txid", txid}, {"endpoint", endpoint.ToHex()}, {"name", name}, diff --git a/llarp/service/outbound_context.cpp b/llarp/service/outbound_context.cpp index b0b865015..22a86d5f9 100644 --- a/llarp/service/outbound_context.cpp +++ b/llarp/service/outbound_context.cpp @@ -535,7 +535,7 @@ namespace llarp bool OutboundContext::HandleHiddenServiceFrame(path::Path* p, - const ProtocolFrame* frame) + const ProtocolFrame& frame) { return m_Endpoint->HandleHiddenServiceFrame(p, frame); } diff --git a/llarp/service/outbound_context.hpp b/llarp/service/outbound_context.hpp index dd4ab82e1..7a5737871 100644 --- a/llarp/service/outbound_context.hpp +++ b/llarp/service/outbound_context.hpp @@ -81,10 +81,10 @@ namespace llarp bool SelectHop(llarp_nodedb* db, const RouterContact& prev, RouterContact& cur, - size_t hop, llarp::path::PathRole roles) override; + size_t hop, path::PathRole roles) override; bool - HandleHiddenServiceFrame(path::Path* p, const ProtocolFrame* frame); + HandleHiddenServiceFrame(path::Path* p, const ProtocolFrame& frame); std::string Name() const override; diff --git a/llarp/service/protocol.cpp b/llarp/service/protocol.cpp index 75f6010ee..313cab593 100644 --- a/llarp/service/protocol.cpp +++ b/llarp/service/protocol.cpp @@ -34,7 +34,7 @@ namespace llarp { ProtocolMessage* self = static_cast< ProtocolMessage* >(user); if(!self->handler->HandleDataMessage(self->srcPath, self)) - llarp::LogWarn("failed to handle data message from ", self->srcPath); + LogWarn("failed to handle data message from ", self->srcPath); delete self; } @@ -170,7 +170,7 @@ namespace llarp } bool - ProtocolFrame::DecryptPayloadInto(llarp::Crypto* crypto, + ProtocolFrame::DecryptPayloadInto(Crypto* crypto, const SharedSecret& sharedkey, ProtocolMessage& msg) const { @@ -181,7 +181,7 @@ namespace llarp } bool - ProtocolFrame::Sign(llarp::Crypto* crypto, const Identity& localIdent) + ProtocolFrame::Sign(Crypto* crypto, const Identity& localIdent) { Z.Zero(); std::array< byte_t, MAX_PROTOCOL_MESSAGE_SIZE > tmp; @@ -189,7 +189,7 @@ namespace llarp // encode if(!BEncode(&buf)) { - llarp::LogError("message too big to encode"); + LogError("message too big to encode"); return false; } // rewind @@ -200,8 +200,7 @@ namespace llarp } bool - ProtocolFrame::EncryptAndSign(llarp::Crypto* crypto, - const ProtocolMessage& msg, + ProtocolFrame::EncryptAndSign(Crypto* crypto, const ProtocolMessage& msg, const SharedSecret& sessionKey, const Identity& localIdent) { @@ -210,7 +209,7 @@ namespace llarp // encode message if(!msg.BEncode(&buf)) { - llarp::LogError("message too big to encode"); + LogError("message too big to encode"); return false; } // rewind @@ -226,8 +225,8 @@ namespace llarp // encode frame if(!BEncode(&buf2)) { - llarp::LogError("frame too big to encode"); - llarp::DumpBuffer(buf2); + LogError("frame too big to encode"); + DumpBuffer(buf2); return false; } // rewind @@ -236,7 +235,7 @@ namespace llarp // sign if(!localIdent.Sign(crypto, Z, buf2)) { - llarp::LogError("failed to sign? wtf?!"); + LogError("failed to sign? wtf?!"); return false; } return true; @@ -244,18 +243,17 @@ namespace llarp struct AsyncFrameDecrypt { - llarp::Crypto* crypto; - llarp::Logic* logic; + Crypto* crypto; + Logic* logic; ProtocolMessage* msg; const Identity& m_LocalIdentity; IDataHandler* handler; const ProtocolFrame frame; const Introduction fromIntro; - AsyncFrameDecrypt(llarp::Logic* l, llarp::Crypto* c, - const Identity& localIdent, IDataHandler* h, - ProtocolMessage* m, const ProtocolFrame& f, - const Introduction& recvIntro) + AsyncFrameDecrypt(Logic* l, Crypto* c, const Identity& localIdent, + IDataHandler* h, ProtocolMessage* m, + const ProtocolFrame& f, const Introduction& recvIntro) : crypto(c) , logic(l) , msg(m) @@ -278,7 +276,7 @@ namespace llarp if(!crypto->pqe_decrypt(self->frame.C, K, pq_keypair_to_secret(self->m_LocalIdentity.pq))) { - llarp::LogError("pqke failed C=", self->frame.C); + LogError("pqke failed C=", self->frame.C); delete self->msg; delete self; return; @@ -288,7 +286,8 @@ namespace llarp crypto->xchacha20(*buf, K, self->frame.N); if(!self->msg->BDecode(buf)) { - llarp::LogError("failed to decode inner protocol message"); + LogError("failed to decode inner protocol message"); + DumpBuffer(*buf); delete self->msg; delete self; return; @@ -296,8 +295,10 @@ namespace llarp // verify signature of outer message after we parsed the inner message if(!self->frame.Verify(crypto, self->msg->sender)) { - llarp::LogError("intro frame has invalid signature Z=", self->frame.Z, - " from ", self->msg->sender.Addr()); + LogError("intro frame has invalid signature Z=", self->frame.Z, + " from ", self->msg->sender.Addr()); + self->frame.Dump< MAX_PROTOCOL_MESSAGE_SIZE >(); + self->msg->Dump< MAX_PROTOCOL_MESSAGE_SIZE >(); delete self->msg; delete self; return; @@ -305,7 +306,7 @@ namespace llarp if(self->handler->HasConvoTag(self->msg->tag)) { - llarp::LogError("dropping duplicate convo tag T=", self->msg->tag); + LogError("dropping duplicate convo tag T=", self->msg->tag); // TODO: send convotag reset delete self->msg; delete self; @@ -321,7 +322,7 @@ namespace llarp if(!self->m_LocalIdentity.KeyExchange(dh_server, sharedSecret, self->msg->sender, self->frame.N)) { - llarp::LogError("x25519 key exchange failed"); + LogError("x25519 key exchange failed"); self->frame.Dump< MAX_PROTOCOL_MESSAGE_SIZE >(); delete self->msg; delete self; @@ -361,7 +362,7 @@ namespace llarp } bool - ProtocolFrame::AsyncDecryptAndVerify(llarp::Logic* logic, llarp::Crypto* c, + ProtocolFrame::AsyncDecryptAndVerify(Logic* logic, Crypto* c, path::Path* recvPath, llarp_threadpool* worker, const Identity& localIdent, @@ -369,7 +370,7 @@ namespace llarp { if(T.IsZero()) { - llarp::LogInfo("Got protocol frame with new convo"); + LogInfo("Got protocol frame with new convo"); ProtocolMessage* msg = new ProtocolMessage(); msg->srcPath = recvPath->RXID(); // we need to dh @@ -381,24 +382,24 @@ namespace llarp SharedSecret shared; if(!handler->GetCachedSessionKeyFor(T, shared)) { - llarp::LogError("No cached session for T=", T); + LogError("No cached session for T=", T); return false; } ServiceInfo si; if(!handler->GetSenderFor(T, si)) { - llarp::LogError("No sender for T=", T); + LogError("No sender for T=", T); return false; } if(!Verify(c, si)) { - llarp::LogError("Signature failure from ", si.Addr()); + LogError("Signature failure from ", si.Addr()); return false; } ProtocolMessage* msg = new ProtocolMessage(); if(!DecryptPayloadInto(c, shared, *msg)) { - llarp::LogError("failed to decrypt message"); + LogError("failed to decrypt message"); delete msg; return false; } @@ -416,7 +417,7 @@ namespace llarp } bool - ProtocolFrame::Verify(llarp::Crypto* crypto, const ServiceInfo& from) const + ProtocolFrame::Verify(Crypto* crypto, const ServiceInfo& from) const { ProtocolFrame copy(*this); // save signature @@ -427,7 +428,7 @@ namespace llarp llarp_buffer_t buf(tmp); if(!copy.BEncode(&buf)) { - llarp::LogError("bencode fail"); + LogError("bencode fail"); return false; } @@ -439,11 +440,10 @@ namespace llarp } bool - ProtocolFrame::HandleMessage(llarp::routing::IMessageHandler* h, - __attribute__((unused)) - AbstractRouter* r) const + ProtocolFrame::HandleMessage(routing::IMessageHandler* h, + ABSL_ATTRIBUTE_UNUSED AbstractRouter* r) const { - return h->HandleHiddenServiceFrame(this); + return h->HandleHiddenServiceFrame(*this); } } // namespace service diff --git a/llarp/service/protocol.hpp b/llarp/service/protocol.hpp index be8d95b96..b223761be 100644 --- a/llarp/service/protocol.hpp +++ b/llarp/service/protocol.hpp @@ -5,9 +5,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include #include #include diff --git a/llarp/service/sendcontext.cpp b/llarp/service/sendcontext.cpp index d19a02963..a505c7032 100644 --- a/llarp/service/sendcontext.cpp +++ b/llarp/service/sendcontext.cpp @@ -28,20 +28,19 @@ namespace llarp if(path) { const routing::PathTransferMessage transfer(msg, remoteIntro.pathID); - if(path->SendRoutingMessage(&transfer, m_Endpoint->Router())) + if(path->SendRoutingMessage(transfer, m_Endpoint->Router())) { - llarp::LogInfo("sent intro to ", remoteIntro.pathID, " on ", - remoteIntro.router, " seqno=", sequenceNo); + LogInfo("sent intro to ", remoteIntro.pathID, " on ", + remoteIntro.router, " seqno=", sequenceNo); lastGoodSend = m_Endpoint->Now(); ++sequenceNo; return true; } else - llarp::LogError("Failed to send frame on path"); + LogError("Failed to send frame on path"); } else - llarp::LogError("cannot send because we have no path to ", - remoteIntro.router); + LogError("cannot send because we have no path to ", remoteIntro.router); return false; } @@ -63,14 +62,13 @@ namespace llarp // shift intro if(MarkCurrentIntroBad(now)) { - llarp::LogInfo("intro shifted"); + LogInfo("intro shifted"); } } auto path = m_PathSet->GetNewestPathByRouter(remoteIntro.router); if(!path) { - llarp::LogError("cannot encrypt and send: no path for intro ", - remoteIntro); + LogError("cannot encrypt and send: no path for intro ", remoteIntro); return; } @@ -87,28 +85,28 @@ namespace llarp m.PutBuffer(payload); if(!f.EncryptAndSign(crypto, m, shared, m_Endpoint->GetIdentity())) { - llarp::LogError("failed to sign"); + LogError("failed to sign"); return; } } else { - llarp::LogError("No cached session key"); + LogError("No cached session key"); return; } msg.P = remoteIntro.pathID; msg.Y.Randomize(); - if(path->SendRoutingMessage(&msg, m_Endpoint->Router())) + if(path->SendRoutingMessage(msg, m_Endpoint->Router())) { - llarp::LogDebug("sent message via ", remoteIntro.pathID, " on ", - remoteIntro.router); + LogDebug("sent message via ", remoteIntro.pathID, " on ", + remoteIntro.router); ++sequenceNo; lastGoodSend = now; } else { - llarp::LogWarn("Failed to send routing message for data"); + LogWarn("Failed to send routing message for data"); } } @@ -121,7 +119,7 @@ namespace llarp { if(!MarkCurrentIntroBad(now)) { - llarp::LogWarn("no good path yet, your message may drop"); + LogWarn("no good path yet, your message may drop"); } } if(sequenceNo) diff --git a/llarp/service/sendcontext.hpp b/llarp/service/sendcontext.hpp index 6239579e1..73dfca717 100644 --- a/llarp/service/sendcontext.hpp +++ b/llarp/service/sendcontext.hpp @@ -2,7 +2,7 @@ #define LLARP_SERVICE_SENDCONTEXT_HPP #include -#include +#include #include #include #include diff --git a/llarp/service/session.hpp b/llarp/service/session.hpp index aad4fd804..73e723eaa 100644 --- a/llarp/service/session.hpp +++ b/llarp/service/session.hpp @@ -3,8 +3,8 @@ #include #include -#include -#include +#include +#include #include #include diff --git a/llarp/service/tag.hpp b/llarp/service/tag.hpp index ab6a562e0..c6061648b 100644 --- a/llarp/service/tag.hpp +++ b/llarp/service/tag.hpp @@ -15,13 +15,13 @@ namespace llarp { namespace service { - struct Tag : public llarp::AlignedBuffer< 16 > + struct Tag : public AlignedBuffer< 16 > { - Tag() : llarp::AlignedBuffer< SIZE >() + Tag() : AlignedBuffer< SIZE >() { } - Tag(const byte_t* d) : llarp::AlignedBuffer< SIZE >(d) + Tag(const byte_t* d) : AlignedBuffer< SIZE >(d) { } diff --git a/llarp/service/tag_lookup_job.cpp b/llarp/service/tag_lookup_job.cpp index 829f9bc74..f3698c4e8 100644 --- a/llarp/service/tag_lookup_job.cpp +++ b/llarp/service/tag_lookup_job.cpp @@ -42,11 +42,11 @@ namespace llarp } } - routing::IMessage* + std::unique_ptr< routing::IMessage > CachedTagResult::BuildRequestMessage(uint64_t txid) { - routing::DHTMessage* msg = new routing::DHTMessage(); - msg->M.emplace_back(new dht::FindIntroMessage(tag, txid)); + auto msg = std::make_unique< routing::DHTMessage >(); + msg->M.emplace_back(std::make_unique< dht::FindIntroMessage >(tag, txid)); lastRequest = parent->Now(); return msg; } diff --git a/llarp/service/tag_lookup_job.hpp b/llarp/service/tag_lookup_job.hpp index 82d91b0ac..76834dd91 100644 --- a/llarp/service/tag_lookup_job.hpp +++ b/llarp/service/tag_lookup_job.hpp @@ -2,7 +2,7 @@ #define LLARP_SERVICE_TAG_LOOKUP_JOB_HPP #include -#include +#include #include #include #include @@ -43,7 +43,7 @@ namespace llarp return (now - lastRequest) > TTL; } - llarp::routing::IMessage* + std::unique_ptr< routing::IMessage > BuildRequestMessage(uint64_t txid); bool @@ -58,7 +58,7 @@ namespace llarp { } - llarp::routing::IMessage* + std::unique_ptr< routing::IMessage > BuildRequestMessage() override { return m_result->BuildRequestMessage(txid); diff --git a/llarp/service/types.cpp b/llarp/service/types.cpp deleted file mode 100644 index f029a29bf..000000000 --- a/llarp/service/types.cpp +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/llarp/service/types.hpp b/llarp/service/types.hpp deleted file mode 100644 index 17a71ed49..000000000 --- a/llarp/service/types.hpp +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef LLARP_SERVICE_TYPES_HPP -#define LLARP_SERVICE_TYPES_HPP -#include -#include - -#endif diff --git a/llarp/service/vanity.hpp b/llarp/service/vanity.hpp index 10cc3eba0..15944a46a 100644 --- a/llarp/service/vanity.hpp +++ b/llarp/service/vanity.hpp @@ -10,7 +10,7 @@ namespace llarp { /// hidden service address - using VanityNonce = llarp::AlignedBuffer< 16 >; + using VanityNonce = AlignedBuffer< 16 >; } // namespace service } // namespace llarp #endif diff --git a/test/dht/mock_context.hpp b/test/dht/mock_context.hpp index 028df7bf3..4e36f7e63 100644 --- a/test/dht/mock_context.hpp +++ b/test/dht/mock_context.hpp @@ -64,7 +64,7 @@ namespace llarp std::vector< std::unique_ptr< dht::IMessage > >& replies)); MOCK_METHOD2(RelayRequestForPath, - bool(const PathID_t& localPath, const dht::IMessage* msg)); + bool(const PathID_t& localPath, const dht::IMessage& msg)); MOCK_CONST_METHOD2(GetRCFromNodeDB, bool(const dht::Key_t& k, RouterContact& rc)); diff --git a/test/dht/test_llarp_dht_serviceaddresslookup.cpp b/test/dht/test_llarp_dht_serviceaddresslookup.cpp index be9168fb4..033a2613e 100644 --- a/test/dht/test_llarp_dht_serviceaddresslookup.cpp +++ b/test/dht/test_llarp_dht_serviceaddresslookup.cpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include #include diff --git a/test/dht/test_llarp_dht_taglookup.cpp b/test/dht/test_llarp_dht_taglookup.cpp index 8a8964cf1..0971d62c8 100644 --- a/test/dht/test_llarp_dht_taglookup.cpp +++ b/test/dht/test_llarp_dht_taglookup.cpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include #include @@ -204,9 +204,13 @@ TEST_F(TestDhtTagLookup, send_reply) { tagLookup.valuesFound.clear(); tagLookup.valuesFound.emplace_back(); - tagLookup.valuesFound.back().T = 1; + tagLookup.valuesFound.back().T = 1; + tagLookup.valuesFound.back().A.vanity[0] = 1; + tagLookup.valuesFound.back().A.UpdateAddr(); tagLookup.valuesFound.emplace_back(); - tagLookup.valuesFound.back().T = 2; + tagLookup.valuesFound.back().T = 2; + tagLookup.valuesFound.back().A.vanity[0] = 2; + tagLookup.valuesFound.back().A.UpdateAddr(); // clang-format off EXPECT_CALL(context, FindRandomIntroSetsWithTagExcluding(_, _, _)).Times(0); diff --git a/test/service/test_llarp_service_identity.cpp b/test/service/test_llarp_service_identity.cpp index 1f4a1f152..d2f32da91 100644 --- a/test/service/test_llarp_service_identity.cpp +++ b/test/service/test_llarp_service_identity.cpp @@ -2,8 +2,8 @@ #include #include #include -#include -#include +#include +#include #include #include