Skip to content

Commit

Permalink
ActiveProxy: reset the internal state of ActiveProxy object when begi…
Browse files Browse the repository at this point in the history
…nning a new connection (#206)
  • Loading branch information
kuit authored Sep 7, 2023
1 parent 70a49de commit aa9e386
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/addons/activeproxy/activeproxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ bool ActiveProxy::needsNewConnection() noexcept

if (connections.empty()) {
if (serverPk.has_value())
serverPk.reset();
reset();
return true;
}

Expand Down
17 changes: 17 additions & 0 deletions src/addons/activeproxy/activeproxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,23 @@ class ActiveProxy : public Addon {

void announcePeer() noexcept;

void reset() noexcept {
sessionKey = CryptoBox::KeyPair();
serverPk.reset();

lastConnectTimestamp = 0;
serverFails = 0;
reconnectDelay = 0;

idleTimestamp = UINT64_MAX;

lastIdleCheckTimestamp = 0;
lastHealthCheckTimestamp = 0;
lastAnnouncePeerTimestamp = 0;

inFlights = 0;
}

private:
Sp<Node> node;

Expand Down

0 comments on commit aa9e386

Please sign in to comment.