track client rcs

pull/350/head
Jeff Becker 5 years ago
parent ab3d435d7f
commit 08d70e6d14
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -509,6 +509,7 @@ namespace llarp
static_cast< async_verify_context * >(job->user); static_cast< async_verify_context * >(job->user);
auto router = ctx->router; auto router = ctx->router;
PubKey pk(job->rc.pubkey); PubKey pk(job->rc.pubkey);
router->m_ClientRCs[pk] = job->rc;
router->FlushOutboundFor(pk, router->GetLinkWithSessionByPubkey(pk)); router->FlushOutboundFor(pk, router->GetLinkWithSessionByPubkey(pk));
delete ctx; delete ctx;
router->pendingVerifyRC.erase(pk); router->pendingVerifyRC.erase(pk);
@ -1039,6 +1040,7 @@ namespace llarp
} }
paths.TickPaths(now); paths.TickPaths(now);
paths.ExpirePaths(now); paths.ExpirePaths(now);
{ {
auto itr = m_PersistingSessions.begin(); auto itr = m_PersistingSessions.begin();
while(itr != m_PersistingSessions.end()) while(itr != m_PersistingSessions.end())
@ -1051,7 +1053,7 @@ namespace llarp
LogDebug("keepalive to ", itr->first); LogDebug("keepalive to ", itr->first);
link->KeepAliveSessionTo(itr->first); link->KeepAliveSessionTo(itr->first);
} }
else else if(m_ClientRCs.count(itr->first) == 0)
{ {
LogDebug("establish to ", itr->first); LogDebug("establish to ", itr->first);
TryEstablishTo(itr->first); TryEstablishTo(itr->first);
@ -1146,9 +1148,11 @@ namespace llarp
void void
Router::SessionClosed(RouterID remote) Router::SessionClosed(RouterID remote)
{ {
__llarp_dht_remove_peer(dht(), remote.data()); dht::Key_t k(remote);
dht()->impl->Nodes()->DelNode(k);
// remove from valid routers if it's a valid router // remove from valid routers if it's a valid router
validRouters.erase(remote); validRouters.erase(remote);
m_ClientRCs.erase(remote);
LogInfo("Session to ", remote, " fully closed"); LogInfo("Session to ", remote, " fully closed");
} }

@ -309,6 +309,9 @@ namespace llarp
std::unordered_map< RouterID, llarp_time_t, RouterID::Hash > std::unordered_map< RouterID, llarp_time_t, RouterID::Hash >
m_PersistingSessions; m_PersistingSessions;
// RCs of connected clients
std::unordered_map< RouterID, RouterContact, RouterID::Hash > m_ClientRCs;
// lokinet routers from lokid, maps pubkey to when we think it will expire, // lokinet routers from lokid, maps pubkey to when we think it will expire,
// set to max value right now // set to max value right now
std::unordered_map< RouterID, llarp_time_t, PubKey::Hash > lokinetRouters; std::unordered_map< RouterID, llarp_time_t, PubKey::Hash > lokinetRouters;

@ -82,6 +82,15 @@ namespace llarp
{ {
} }
struct Hash
{
size_t
operator()(const RouterContact &r) const
{
return PubKey::Hash()(r.pubkey);
}
};
// advertised addresses // advertised addresses
std::vector< AddressInfo > addrs; std::vector< AddressInfo > addrs;
// network identifier // network identifier

Loading…
Cancel
Save