|
|
@ -195,9 +195,12 @@ namespace data |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void NetDb::AddLeaseSet (const IdentHash& ident, const uint8_t * buf, int len) |
|
|
|
void NetDb::AddLeaseSet (const IdentHash& ident, const uint8_t * buf, int len, |
|
|
|
|
|
|
|
i2p::tunnel::InboundTunnel * from) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
DeleteRequestedDestination (ident); |
|
|
|
|
|
|
|
if (!from) // unsolicited LS must be received directly
|
|
|
|
{ |
|
|
|
{ |
|
|
|
bool unsolicited = !DeleteRequestedDestination (ident); |
|
|
|
|
|
|
|
auto it = m_LeaseSets.find(ident); |
|
|
|
auto it = m_LeaseSets.find(ident); |
|
|
|
if (it != m_LeaseSets.end ()) |
|
|
|
if (it != m_LeaseSets.end ()) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -207,7 +210,8 @@ namespace data |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint ("New LeaseSet added"); |
|
|
|
LogPrint ("New LeaseSet added"); |
|
|
|
m_LeaseSets[ident] = new LeaseSet (buf, len, unsolicited); |
|
|
|
m_LeaseSets[ident] = new LeaseSet (buf, len); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -427,7 +431,7 @@ namespace data |
|
|
|
if (msg->type) |
|
|
|
if (msg->type) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint ("LeaseSet"); |
|
|
|
LogPrint ("LeaseSet"); |
|
|
|
AddLeaseSet (msg->key, buf + offset, len - offset); |
|
|
|
AddLeaseSet (msg->key, buf + offset, len - offset, m->from); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
@ -635,7 +639,7 @@ namespace data |
|
|
|
if (!replyMsg) |
|
|
|
if (!replyMsg) |
|
|
|
{ |
|
|
|
{ |
|
|
|
auto leaseSet = FindLeaseSet (buf); |
|
|
|
auto leaseSet = FindLeaseSet (buf); |
|
|
|
if (leaseSet && leaseSet->IsUnsolicited ()) // we don't send back our LeaseSets
|
|
|
|
if (leaseSet) // we don't send back our LeaseSets
|
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint ("Requested LeaseSet ", key, " found"); |
|
|
|
LogPrint ("Requested LeaseSet ", key, " found"); |
|
|
|
replyMsg = CreateDatabaseStoreMsg (leaseSet); |
|
|
|
replyMsg = CreateDatabaseStoreMsg (leaseSet); |
|
|
@ -885,8 +889,6 @@ namespace data |
|
|
|
LogPrint ("LeaseSet requested"); |
|
|
|
LogPrint ("LeaseSet requested"); |
|
|
|
RequestDestination (ident, true, pool); |
|
|
|
RequestDestination (ident, true, pool); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
|
|
|
|
leaseSet->SetUnsolicited (false); |
|
|
|
|
|
|
|
m_Subscriptions[ident] = pool; |
|
|
|
m_Subscriptions[ident] = pool; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -920,7 +922,7 @@ namespace data |
|
|
|
{ |
|
|
|
{ |
|
|
|
for (auto it = m_LeaseSets.begin (); it != m_LeaseSets.end ();) |
|
|
|
for (auto it = m_LeaseSets.begin (); it != m_LeaseSets.end ();) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (it->second->IsUnsolicited () && !it->second->HasNonExpiredLeases ()) // all leases expired
|
|
|
|
if (it->second->HasNonExpiredLeases ()) // all leases expired
|
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint ("LeaseSet ", it->second->GetIdentHash ().ToBase64 (), " expired"); |
|
|
|
LogPrint ("LeaseSet ", it->second->GetIdentHash ().ToBase64 (), " expired"); |
|
|
|
delete it->second; |
|
|
|
delete it->second; |
|
|
|