r/learnrust • • 15d ago

A userspace TUN VPN/privacy relay in Rust

a vpn app in rust facing issue where if corrupt pack arrives worker crashes which is cutting users video call or connection how to design where i can sideline or disregard or discard that packet so users connections doesnt breaks & i dont have to go safety checks for every line.

0 Upvotes

1 comment sorted by

2

u/Discordbothost 15d ago

Make packet parsing return Result<Packet, ParseError>, then handle Err by dropping that packet and continuing the receive loop. Keep length/field validation inside the parser so downstream code gets a validated Packet. What's the panic message? An unwrap and an out-of-bounds slice need different fixes.