diff --git a/llarp/messages/relay_commit.cpp b/llarp/messages/relay_commit.cpp index 8abebf9b8..402a0b043 100644 --- a/llarp/messages/relay_commit.cpp +++ b/llarp/messages/relay_commit.cpp @@ -322,6 +322,9 @@ namespace llarp self->hop = nullptr; } + // TODO: If decryption has succeeded here but we otherwise don't + // want to or can't accept the path build request, send + // a status message saying as much. static void HandleDecrypted(llarp_buffer_t* buf, std::shared_ptr< LRCMFrameDecrypt > self) @@ -344,8 +347,16 @@ namespace llarp return; } - info.txID = self->record.txid; - info.rxID = self->record.rxid; + info.txID = self->record.txid; + info.rxID = self->record.rxid; + + if(info.txID.IsZero() || info.rxID.IsZero()) + { + llarp::LogError("LRCM refusing zero pathid"); + self->decrypter = nullptr; + return; + } + info.upstream = self->record.nextHop; // generate path key as we are in a worker thread diff --git a/llarp/path/path.cpp b/llarp/path/path.cpp index 975ba028b..0291da07f 100644 --- a/llarp/path/path.cpp +++ b/llarp/path/path.cpp @@ -31,8 +31,14 @@ namespace llarp for(size_t idx = 0; idx < hsz; ++idx) { hops[idx].rc = h[idx]; - hops[idx].txID.Randomize(); - hops[idx].rxID.Randomize(); + while(hops[idx].txID.IsZero()) + { + hops[idx].txID.Randomize(); + } + while(hops[idx].rxID.IsZero()) + { + hops[idx].rxID.Randomize(); + } } for(size_t idx = 0; idx < hsz - 1; ++idx) diff --git a/llarp/router/outbound_message_handler.cpp b/llarp/router/outbound_message_handler.cpp index 69f9f81a6..4bf392aec 100644 --- a/llarp/router/outbound_message_handler.cpp +++ b/llarp/router/outbound_message_handler.cpp @@ -263,14 +263,7 @@ namespace llarp void OutboundMessageHandler::RemoveEmptyPathQueues() { - if(not removedPaths.empty()) - { - removedSomePaths = true; - } - else - { - removedSomePaths = false; - } + removedSomePaths = (not removedPaths.empty()); while(not removedPaths.empty()) { diff --git a/llarp/router/outbound_message_handler.hpp b/llarp/router/outbound_message_handler.hpp index 2f0b12084..84e6d6f45 100644 --- a/llarp/router/outbound_message_handler.hpp +++ b/llarp/router/outbound_message_handler.hpp @@ -123,7 +123,9 @@ namespace llarp ILinkManager *_linkManager; std::shared_ptr< Logic > _logic; - const PathID_t zeroID; + // paths cannot have pathid "0", so it can be used as the "pathid" + // for non-traffic (control) messages, so they can be prioritized. + static const PathID_t zeroID; }; } // namespace llarp