close stale sessions on thaw because they are probably already gone. this removes them and forces the sessions to be renegotiated.

pull/1532/head
Jeff Becker 3 years ago
parent ffef3bc48f
commit 676ca7f511
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -70,6 +70,9 @@ namespace llarp
virtual void
ForEachInboundLink(std::function<void(LinkLayer_ptr)> visit) const = 0;
virtual void
ForEachOutboundLink(std::function<void(LinkLayer_ptr)> visit) const = 0;
/// close all connections to this peer
/// remove all link layer commits
virtual void

@ -225,6 +225,15 @@ namespace llarp
}
}
void
LinkManager::ForEachOutboundLink(std::function<void(LinkLayer_ptr)> visit) const
{
for (const auto& link : outboundLinks)
{
visit(link);
}
}
size_t
LinkManager::NumberOfConnectedRouters() const
{

@ -65,6 +65,9 @@ namespace llarp
void
ForEachInboundLink(std::function<void(LinkLayer_ptr)> visit) const override;
void
ForEachOutboundLink(std::function<void(LinkLayer_ptr)> visit) const override;
size_t
NumberOfConnectedRouters() const override;

@ -125,6 +125,19 @@ namespace llarp
Router::Thaw()
{
LogInfo("We arise from a long sleep, probably need to reset the network state");
// get pubkeys we are connected to
std::unordered_set<RouterID> peerPubkeys;
linkManager().ForEachPeer([&peerPubkeys](auto peer) {
if (not peer)
return;
peerPubkeys.emplace(peer->GetPubKey());
});
// close our sessions to them on link layer
linkManager().ForEachOutboundLink([peerPubkeys](const auto& link) {
for (const auto& remote : peerPubkeys)
link->CloseSessionTo(remote);
});
// thaw endpoints
hiddenServiceContext().ForEachService([](const auto& name, const auto& ep) -> bool {
LogInfo(name, " thawing...");
ep->Thaw();

Loading…
Cancel
Save