Skip to content

refactor(yipd): split peer_manager.rs into a module directory (keep the struct whole) #108

Description

@vxfemboy

peer_manager.rs is a god-STRUCT: PeerManager has 26 fields and one ~3300-line impl (plus ~6000 test lines) spanning 7 clean method clusters (handshake, rekey, relay, routing, obf, gossip/admission, Dispatch). Every change to any subsystem edits the same file. Do NOT extract collaborator structs — methods take &mut self and return DispatchOut<'_> borrowing from self (tun_scratch already documents a borrow-checker workaround), so splitting the struct turns every seam into a borrow conflict. Instead mechanically move method clusters into sibling files under peer_manager/, each with its own impl PeerManager + mod tests, zero behavior change: mod.rs (struct+fields+new+Dispatch), handshake.rs, rekey.rs, relay.rs, routing.rs, obf.rs, gossip.rs. Phase 2 (optional): extract {obf_key,junk_rng,cover_traffic_ms}->ObfState and {last_register_ms,reg_refresh_ms,registered_once,reg_seq}->RegistrationState (neither participates in the DispatchOut borrow). Same treatment applies to yip-utls/src/stream.rs (~1770 lines, free functions -> cert.rs/record.rs/sig.rs/flight.rs/stream.rs).

See docs/2026-07-25-project-review-and-roadmap.md for the full review synthesis.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions