fix introset expiration

pull/25/head
Jeff 6 years ago
parent fd37100ac8
commit 0023c15d0f

@ -109,8 +109,6 @@ namespace llarp
bool
IntroSet::IsExpired(llarp_time_t now) const
{
if(now > T)
return false;
return now - T > DEFAULT_PATH_LIFETIME;
}

@ -644,6 +644,7 @@ namespace llarp
void
Endpoint::PutNewOutboundContext(const llarp::service::IntroSet& introset)
{
Address addr;
introset.A.CalculateAddress(addr.data());
@ -843,7 +844,8 @@ namespace llarp
bool
Endpoint::OnOutboundLookup(const Address& addr, const IntroSet* introset)
{
if(!introset)
auto now = llarp_time_now_ms();
if(introset == nullptr || introset->IsExpired(now))
{
auto itr = m_PendingServiceLookups.find(addr);
if(itr != m_PendingServiceLookups.end())
@ -964,6 +966,12 @@ namespace llarp
llarp::LogInfo("introset is old, dropping");
return true;
}
auto now = llarp_time_now_ms();
if(i->IsExpired(now))
{
llarp::LogError("got expired introset from lookup");
return true;
}
currentIntroSet = *i;
if(!ShiftIntroduction())
{

@ -32,6 +32,7 @@ TEST_F(HiddenServiceTest, TestGenerateIntroSet)
ASSERT_TRUE(ident.pub.CalculateAddress(addr.data()));
llarp::service::IntroSet I;
auto now = llarp_time_now_ms();
I.T = now;
while(I.I.size() < 10)
{
llarp::service::Introduction intro;

Loading…
Cancel
Save