mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-11-11 07:10:36 +00:00
Merge pull request #621 from majestrate/master
double path build timeout from 15s to 30s
This commit is contained in:
commit
82491305dd
@ -41,7 +41,8 @@ namespace llarp
|
|||||||
r->netloop())
|
r->netloop())
|
||||||
, m_NetworkToUserPktQueue(nickname + "_recvq", r->netloop(),
|
, m_NetworkToUserPktQueue(nickname + "_recvq", r->netloop(),
|
||||||
r->netloop())
|
r->netloop())
|
||||||
, m_Resolver(std::make_shared<dns::Proxy>(r->netloop(), r->logic(), r->netloop(), r->logic(), this))
|
, m_Resolver(std::make_shared< dns::Proxy >(
|
||||||
|
r->netloop(), r->logic(), r->netloop(), r->logic(), this))
|
||||||
{
|
{
|
||||||
#ifdef ANDROID
|
#ifdef ANDROID
|
||||||
tunif.get_fd_promise = &get_tun_fd_promise;
|
tunif.get_fd_promise = &get_tun_fd_promise;
|
||||||
|
@ -42,7 +42,7 @@ namespace llarp
|
|||||||
/// default path lifetime in ms
|
/// default path lifetime in ms
|
||||||
constexpr llarp_time_t default_lifetime = 10 * 60 * 1000;
|
constexpr llarp_time_t default_lifetime = 10 * 60 * 1000;
|
||||||
/// after this many ms a path build times out
|
/// after this many ms a path build times out
|
||||||
constexpr llarp_time_t build_timeout = 15000;
|
constexpr llarp_time_t build_timeout = 30000;
|
||||||
|
|
||||||
/// measure latency every this interval ms
|
/// measure latency every this interval ms
|
||||||
constexpr llarp_time_t latency_interval = 5000;
|
constexpr llarp_time_t latency_interval = 5000;
|
||||||
|
@ -332,61 +332,33 @@ namespace llarp
|
|||||||
OutboundContext::MarkCurrentIntroBad(llarp_time_t now)
|
OutboundContext::MarkCurrentIntroBad(llarp_time_t now)
|
||||||
{
|
{
|
||||||
// insert bad intro
|
// insert bad intro
|
||||||
m_BadIntros[remoteIntro] = now;
|
m_BadIntros[m_NextIntro] = now;
|
||||||
// unconditional shift
|
// try shifting intro without rebuild
|
||||||
bool shiftedRouter = false;
|
if(ShiftIntroduction(false))
|
||||||
bool shiftedIntro = false;
|
|
||||||
// try same router
|
|
||||||
for(const auto& intro : currentIntroSet.I)
|
|
||||||
{
|
{
|
||||||
if(intro.ExpiresSoon(now))
|
// we shifted
|
||||||
continue;
|
// check if we have a path to the next intro router
|
||||||
if(router->routerProfiling().IsBadForPath(intro.router))
|
if(GetNewestPathByRouter(m_NextIntro.router))
|
||||||
continue;
|
return true;
|
||||||
auto itr = m_BadIntros.find(intro);
|
// we don't have a path build one if we aren't building too fast
|
||||||
if(itr == m_BadIntros.end() && intro.router == m_NextIntro.router)
|
|
||||||
{
|
|
||||||
if(intro.expiresAt > m_NextIntro.expiresAt)
|
|
||||||
{
|
|
||||||
shiftedIntro = true;
|
|
||||||
m_NextIntro = intro;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!shiftedIntro)
|
|
||||||
{
|
|
||||||
// try any router
|
|
||||||
for(const auto& intro : currentIntroSet.I)
|
|
||||||
{
|
|
||||||
if(intro.ExpiresSoon(now))
|
|
||||||
continue;
|
|
||||||
auto itr = m_BadIntros.find(intro);
|
|
||||||
if(itr == m_BadIntros.end())
|
|
||||||
{
|
|
||||||
// TODO: this should always be true but idk if it really is
|
|
||||||
if(intro.expiresAt > m_NextIntro.expiresAt)
|
|
||||||
{
|
|
||||||
shiftedRouter = m_NextIntro.router != intro.router;
|
|
||||||
shiftedIntro = true;
|
|
||||||
m_NextIntro = intro;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(shiftedRouter)
|
|
||||||
{
|
|
||||||
lastShift = now;
|
|
||||||
if(!BuildCooldownHit(now))
|
if(!BuildCooldownHit(now))
|
||||||
BuildOneAlignedTo(m_NextIntro.router);
|
BuildOneAlignedTo(m_NextIntro.router);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
else if(!shiftedIntro)
|
else
|
||||||
{
|
{
|
||||||
|
// we didn't shift check if we should update introset
|
||||||
|
if(now - lastShift >= MIN_SHIFT_INTERVAL
|
||||||
|
|| currentIntroSet.HasExpiredIntros(now)
|
||||||
|
|| currentIntroSet.IsExpired(now))
|
||||||
|
{
|
||||||
|
// update introset
|
||||||
LogInfo(Name(), " updating introset");
|
LogInfo(Name(), " updating introset");
|
||||||
UpdateIntroSet(true);
|
UpdateIntroSet(true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return shiftedIntro;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@ -409,11 +381,14 @@ namespace llarp
|
|||||||
{
|
{
|
||||||
if(intro.expiresAt > m_NextIntro.expiresAt)
|
if(intro.expiresAt > m_NextIntro.expiresAt)
|
||||||
{
|
{
|
||||||
|
success = true;
|
||||||
m_NextIntro = intro;
|
m_NextIntro = intro;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(!success)
|
||||||
|
{
|
||||||
/// pick newer intro not on same router
|
/// pick newer intro not on same router
|
||||||
for(const auto& intro : currentIntroSet.I)
|
for(const auto& intro : currentIntroSet.I)
|
||||||
{
|
{
|
||||||
@ -422,7 +397,8 @@ namespace llarp
|
|||||||
m_Endpoint->EnsureRouterIsKnown(intro.router);
|
m_Endpoint->EnsureRouterIsKnown(intro.router);
|
||||||
if(intro.ExpiresSoon(now))
|
if(intro.ExpiresSoon(now))
|
||||||
continue;
|
continue;
|
||||||
if(m_BadIntros.find(intro) == m_BadIntros.end() && m_NextIntro != intro)
|
if(m_BadIntros.find(intro) == m_BadIntros.end()
|
||||||
|
&& m_NextIntro != intro)
|
||||||
{
|
{
|
||||||
if(intro.expiresAt > m_NextIntro.expiresAt)
|
if(intro.expiresAt > m_NextIntro.expiresAt)
|
||||||
{
|
{
|
||||||
@ -432,14 +408,13 @@ namespace llarp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if(m_NextIntro.router.IsZero())
|
if(m_NextIntro.router.IsZero())
|
||||||
return false;
|
return false;
|
||||||
if(shifted)
|
if(shifted)
|
||||||
{
|
|
||||||
lastShift = now;
|
lastShift = now;
|
||||||
if(rebuild && !BuildCooldownHit(Now()))
|
if(rebuild && !BuildCooldownHit(Now()))
|
||||||
BuildOneAlignedTo(m_NextIntro.router);
|
BuildOneAlignedTo(m_NextIntro.router);
|
||||||
}
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -496,7 +471,9 @@ namespace llarp
|
|||||||
// check if we have a path to this router
|
// check if we have a path to this router
|
||||||
num = 0;
|
num = 0;
|
||||||
ForEachPath([&](const path::Path_ptr& p) {
|
ForEachPath([&](const path::Path_ptr& p) {
|
||||||
if(p->Endpoint() == m_NextIntro.router)
|
// don't count timed out paths
|
||||||
|
if(p->Status() != path::ePathTimeout
|
||||||
|
&& p->Endpoint() == m_NextIntro.router)
|
||||||
++num;
|
++num;
|
||||||
});
|
});
|
||||||
// build a path if one isn't already pending build or established
|
// build a path if one isn't already pending build or established
|
||||||
|
Loading…
Reference in New Issue
Block a user