diff --git a/llarp/dht/messages/findintro.cpp b/llarp/dht/messages/findintro.cpp index 715242471..e3a9a7ea3 100644 --- a/llarp/dht/messages/findintro.cpp +++ b/llarp/dht/messages/findintro.cpp @@ -89,7 +89,7 @@ namespace llarp llarp::LogWarn("duplicate FIM from ", From, " txid=", txID); return false; } - Key_t peer; + std::set< Key_t > exclude = {dht.OurKey(), From}; if(not tagName.Empty()) return false; @@ -112,26 +112,24 @@ namespace llarp if(recursionDepth == 0) { // we don't have it - - Key_t closer; - // find closer peer - if(!dht.Nodes()->FindClosest(location, closer)) - return false; - replies.emplace_back(new GotIntroMessage(From, closer, txID)); + replies.emplace_back(new GotIntroMessage({}, txID)); return true; } // we are recursive const auto rc = dht.GetRouter()->nodedb()->FindClosestTo(location); - peer = Key_t(rc.pubkey); + Key_t peer = Key_t(rc.pubkey); - if((us ^ location) < (peer ^ location) || peer == us) + if((us ^ location) <= (peer ^ location)) { - // we are not closer than our peer to the target so don't - // recurse farther - replies.emplace_back(new GotIntroMessage({}, txID)); - return true; + // ask second closest as we are recursive + if(not dht.Nodes()->FindCloseExcluding(location, peer, exclude)) + { + // no second closeset + replies.emplace_back(new GotIntroMessage({}, txID)); + return true; + } } if(relayed) { diff --git a/llarp/service/hidden_service_address_lookup.cpp b/llarp/service/hidden_service_address_lookup.cpp index 5b791bc30..49a63ff38 100644 --- a/llarp/service/hidden_service_address_lookup.cpp +++ b/llarp/service/hidden_service_address_lookup.cpp @@ -46,8 +46,8 @@ namespace llarp HiddenServiceAddressLookup::BuildRequestMessage() { auto msg = std::make_shared< routing::DHTMessage >(); - msg->M.emplace_back(std::make_unique< dht::FindIntroMessage >( - txid, location, dht::FindIntroMessage::MaxRecursionDepth)); + msg->M.emplace_back( + std::make_unique< dht::FindIntroMessage >(txid, location, 2)); return msg; }