pub struct PathRegistry { /* private fields */ }Expand description
Per-session collection of PathStates indexed by path_id.
Lock-free in the steady state (DashMap is lock-free for reads);
per-path validation operations take only the per-path Mutex on
the pending challenge, which is uncontended outside of the brief
window of an active challenge round-trip.
Implementations§
Source§impl PathRegistry
impl PathRegistry
pub fn new() -> Self
Sourcepub fn register(&self, path_id: u8) -> RegistrationResult
pub fn register(&self, path_id: u8) -> RegistrationResult
Register a new path id if it doesn’t already exist. Returns
Created if this call created the entry — caller is the one
that should now issue a validation challenge.
Sourcepub fn register_validated(&self, path_id: u8) -> RegistrationResult
pub fn register_validated(&self, path_id: u8) -> RegistrationResult
Register a new path id directly in the Validated state, skipping
the challenge-response round trip. Used for the implicit
path_id = 0 initialised at session establishment — that path
is the one the handshake itself traversed, so the AEAD setup
itself was already a stronger proof of reachability than any
PATH_CHALLENGE would be.
Returns Created if this call created the entry. If the entry
already existed, its state is NOT modified — the caller must
explicitly drive a challenge-response if they want to change it.
Sourcepub fn mark_seen(&self, path_id: u8)
pub fn mark_seen(&self, path_id: u8)
Update last_packet_seen on the path. No-op for unknown paths.
Sourcepub fn issue_challenge(&self, path_id: u8) -> Option<[u8; 32]>
pub fn issue_challenge(&self, path_id: u8) -> Option<[u8; 32]>
Allocate a fresh challenge for the path and transition it to
Validating. The caller is responsible for transmitting the
returned bytes (typically inside a PATH_VALIDATION-flagged V2
packet).
Returns None if the path is unknown or if it is already in
Validated / Failed (re-issuing a challenge from those
terminal states is the caller’s explicit decision).
Sourcepub fn verify_response(&self, path_id: u8, response: &[u8]) -> bool
pub fn verify_response(&self, path_id: u8, response: &[u8]) -> bool
Verify a peer’s response to a previously-issued challenge. On a
constant-time match, transitions the path to Validated and
returns true. On mismatch or unknown state, transitions to
Failed and returns false. On unknown path, returns false
without side-effects.
subtle::ConstantTimeEq is used so a timing observer cannot
distinguish “wrong byte at position 0” from “wrong byte at
position 31” — same posture as the cookie check in
transport::handshake::validate_cookie.
Sourcepub fn state(&self, path_id: u8) -> Option<PathStateKind>
pub fn state(&self, path_id: u8) -> Option<PathStateKind>
Current state of a path. Returns None for unknown ids.
Sourcepub fn validated_paths(&self) -> Vec<u8> ⓘ
pub fn validated_paths(&self) -> Vec<u8> ⓘ
Snapshot of all path ids currently in Validated.