node: derive handshake state from the peer machine, delete the leg field

The connection leg's HandshakeState field duplicated the peer machine's
handshake phase. Delete it and derive the displayed handshake state string
from the machine's PeerState, looked up by link id (mirroring the resend
count). Move the failure signal onto the machine: a send_failed flag that
preserves retransmit eligibility (the machine stays in its handshake phase),
alongside the existing Failed state. The leg's crypto self-gates now guard on
Noise handle presence instead of the deleted phase field, and mark_failed
only drops the handle. Telemetry strings, wire bytes, index allocation, and
the stale-connection reaping are byte-identical for all normal paths.
This commit is contained in:
Johnathan Corgan
2026-07-18 02:26:39 +00:00
parent b38f8c6ffb
commit 56bbc81a40
12 changed files with 266 additions and 241 deletions
+12 -1
View File
@@ -1981,7 +1981,7 @@ impl Node {
.map(|conn| snap::ConnectionRow {
link_id: conn.link_id().as_u64(),
direction: format!("{}", conn.direction()),
handshake_state: format!("{}", conn.handshake_state()),
handshake_state: self.connection_handshake_state(conn.link_id()).to_string(),
started_at_ms: conn.started_at(),
last_activity_ms: conn.last_activity(),
resend_count: self.connection_resend_count(conn.link_id()),
@@ -2309,6 +2309,17 @@ impl Node {
.map_or(0, |machine| machine.resend_count())
}
/// Operator-visible handshake-state string for a pending handshake `link`,
/// derived from the per-peer control machine (the phase's home now that the
/// leg no longer carries it). Every leg surfaced by `connections()` is
/// embedded in a machine, so the lookup resolves; the `"initial"` default is
/// unreachable in that view and only guards a missing machine.
pub(crate) fn connection_handshake_state(&self, link: LinkId) -> &'static str {
self.peer_machines
.get(&link)
.map_or("initial", |machine| machine.displayed_handshake_state())
}
pub(crate) fn cleanup_bootstrap_transport_if_unused(&mut self, transport_id: TransportId) {
if !self
.supervisor