Merge pull request #525 from majestrate/master

fix dht and exit paths
pull/527/head
Jeff 5 years ago committed by GitHub
commit 88c2e73ab0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -40,9 +40,14 @@ namespace llarp
replies.emplace_back(new GotRouterMessage(k, txid, {found}, false));
return true;
}
// lookup if we don't have it in our nodedb
if(dht.Nodes()->FindClosest(k, peer))
dht.LookupRouterForPath(K, txid, pathID, peer);
if((!dht.Nodes()->FindClosest(k, peer)) || peer == us)
{
// can't find any peers closer
replies.emplace_back(new GotRouterMessage(k, txid, {}, false));
return true;
}
// lookup if we don't have it in our nodedb
dht.LookupRouterForPath(K, txid, pathID, peer);
return true;
}

@ -81,6 +81,12 @@ namespace llarp
return path::Builder::SelectHop(db, prev, cur, hop, roles);
}
bool
BaseSession::CheckPathDead(path::Path *, llarp_time_t dlt)
{
return dlt >= 10000;
}
void
BaseSession::HandlePathBuilt(llarp::path::Path* p)
{
@ -88,7 +94,7 @@ namespace llarp
p->SetDropHandler(std::bind(&BaseSession::HandleTrafficDrop, this,
std::placeholders::_1, std::placeholders::_2,
std::placeholders::_3));
p->SetDeadChecker(std::bind(&BaseSession::CheckPathDead, this, std::placeholders::_1, std::placeholders::_2));
p->SetExitTrafficHandler(
std::bind(&BaseSession::HandleTraffic, this, std::placeholders::_1,
std::placeholders::_2, std::placeholders::_3));

@ -35,6 +35,9 @@ namespace llarp
void
HandlePathDied(llarp::path::Path* p) override;
bool
CheckPathDead(path::Path * p, llarp_time_t dlt);
bool
SelectHop(llarp_nodedb* db, const RouterContact& prev, RouterContact& cur,
size_t hop, llarp::path::PathRole roles) override;

Loading…
Cancel
Save