Merge pull request #1089 from majestrate/dht-introset-lookup-relayed-try-closer-2020-02-07

try closer router if relayed
pull/1092/head
Jeff 4 years ago committed by GitHub
commit 80a7b788bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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)
{

@ -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;
}

Loading…
Cancel
Save