From 5b49008bca4251cb8b6e772672341f9f3d286640 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Thu, 2 May 2019 12:23:31 -0400 Subject: [PATCH] more --- llarp/hook/shell.cpp | 3 +-- llarp/net/net_int.cpp | 8 ++++---- llarp/service/endpoint.cpp | 23 +++++++++++++---------- llarp/service/outbound_context.cpp | 4 +--- llarp/service/sendcontext.cpp | 1 - 5 files changed, 19 insertions(+), 20 deletions(-) diff --git a/llarp/hook/shell.cpp b/llarp/hook/shell.cpp index d152175fb..fef455a84 100644 --- a/llarp/hook/shell.cpp +++ b/llarp/hook/shell.cpp @@ -16,8 +16,7 @@ namespace llarp namespace hooks { #if defined(_WIN32) - Backend_ptr - ExecShellBackend(std::string) + Backend_ptr ExecShellBackend(std::string) { return nullptr; } diff --git a/llarp/net/net_int.cpp b/llarp/net/net_int.cpp index 782d2fafe..0e3540710 100644 --- a/llarp/net/net_int.cpp +++ b/llarp/net/net_int.cpp @@ -32,15 +32,15 @@ namespace llarp return ""; return tmp; } - template<> - std::string + template <> + std::string huint16_t::ToString() const { return std::to_string(h); } - template<> - std::string + template <> + std::string nuint16_t::ToString() const { return std::to_string(ntohs(n)); diff --git a/llarp/service/endpoint.cpp b/llarp/service/endpoint.cpp index e8fc2c790..13cb7215f 100644 --- a/llarp/service/endpoint.cpp +++ b/llarp/service/endpoint.cpp @@ -741,8 +741,7 @@ namespace llarp { if(router.IsZero()) return; - RouterContact rc; - if(!m_Router->nodedb()->Get(router, rc)) + if(!m_Router->nodedb()->Has(router)) { LookupRouterAnon(router); } @@ -880,9 +879,13 @@ namespace llarp if(!f.Sign(crypto(), m_Identity)) return false; - auto d = - std::make_shared< const routing::PathTransferMessage >(f, frame.F); - RouterLogic()->queue_func([=]() { p->SendRoutingMessage(*d, router); }); + { + util::Lock lock(&m_SendQueueMutex); + m_SendQueue.emplace_back( + std::make_shared< const routing::PathTransferMessage >(f, + frame.F), + p); + } return true; } return true; @@ -1156,20 +1159,20 @@ namespace llarp bool Endpoint::ShouldBuildMore(llarp_time_t now) const { - bool should = path::Builder::ShouldBuildMore(now); + const bool should = path::Builder::ShouldBuildMore(now); // determine newest intro Introduction intro; if(!GetNewestIntro(intro)) return should; // time from now that the newest intro expires at - if(now >= intro.expiresAt) + if(intro.ExpiresSoon(now)) return should; - auto dlt = now - intro.expiresAt; + const auto dlt = now - intro.expiresAt; return should || ( // try spacing tunnel builds out evenly in time - (dlt < (path::default_lifetime / 2)) + (dlt > (path::default_lifetime / 4)) && (NumInStatus(path::ePathBuilding) < m_NumPaths) - && (dlt > buildIntervalLimit)); + && (dlt >= buildIntervalLimit)); } Logic* diff --git a/llarp/service/outbound_context.cpp b/llarp/service/outbound_context.cpp index 31ada71e8..ff55258d8 100644 --- a/llarp/service/outbound_context.cpp +++ b/llarp/service/outbound_context.cpp @@ -298,8 +298,7 @@ namespace llarp } } // lookup router in intro if set and unknown - if(!remoteIntro.router.IsZero()) - m_Endpoint->EnsureRouterIsKnown(remoteIntro.router); + m_Endpoint->EnsureRouterIsKnown(remoteIntro.router); // expire bad intros auto itr = m_BadIntros.begin(); while(itr != m_BadIntros.end()) @@ -322,7 +321,6 @@ namespace llarp tmp.Randomize(); llarp_buffer_t buf(tmp.data(), tmp.size()); AsyncEncryptAndSendTo(buf, eProtocolControl); - SharedSecret k; if(currentConvoTag.IsZero()) return false; return !m_DataHandler->HasConvoTag(currentConvoTag); diff --git a/llarp/service/sendcontext.cpp b/llarp/service/sendcontext.cpp index 585499b2c..16e890f22 100644 --- a/llarp/service/sendcontext.cpp +++ b/llarp/service/sendcontext.cpp @@ -101,7 +101,6 @@ namespace llarp LogError("No cached session key"); return; } - ++sequenceNo; Send(f, path); }