You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(backend): dedupe TUN reader routing and slim stats snapshot (#173)
The TUN reader hot loop in `spawn_tun_reader` had the IPv4 and IPv6
packet-delivery logic copy-pasted: ~50 lines that differed only in the
peer map and the `no_peer` counter. The send-outcome handling (routed /
channel-full drop accounting / closed -> remove_peer_if_same) was
identical, so a fix to the send path could silently drift between the
two address families.
- Extract a generic `deliver_to_client<K>()` helper over the map key
type; collapse the branches into a `match packet[0] >> 4`.
- Derive `Clone, Copy` on `TunReaderStats` and replace the manual
9-field `*previous = Self { .. }` snapshot with `*previous = *self`,
so adding a field later can't silently corrupt per-interval deltas.
Pure structural cleanup, behavior unchanged. cargo build/clippy clean;
all 150 backend tests pass (including the reused-IP race guards).
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
0 commit comments