tokio
tokio copied to clipboard
UdpFramed decode errors hide the source of the malformed packet
When using UdpFramed, receiving data bundles the received item with the source SocketAddr but if there is a decode error, the error is delivered directly without the accompanying source SocketAddr. This means that developers cannot meaningfully identify malfunctioning peers even to just print debugging to figure out what's gone wrong.
I believe a reasonable solution is to simply change the Item type to:
type Item = Result<(C::Item, SocketAddr), (C::Error, Option<SocketAddr>)>;
The Option<SocketAddr> is needed as there is a case we get an I/O error in poll_recv_from and we don't have the address available from the underlying syscall.
This is a breaking API change of course, but I'm not quite sure if that's something tokio-util needs to be sensitive to.
This seems fine
Not sure when we will make a breaking release of tokio-util next, but seems fine to include next time we do so.
I'll take a crack at a PR