Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lossy serialization of SocketAddrV6 #2618

Open
benmaddison opened this issue Sep 20, 2023 · 0 comments
Open

Lossy serialization of SocketAddrV6 #2618

benmaddison opened this issue Sep 20, 2023 · 0 comments

Comments

@benmaddison
Copy link

The non-human readable serialization of SocketAddrV6 (and by extension SocketAddr) encodes only IP address and port information, omitting flow info and scope:

#[cfg(feature = "std")]
impl Serialize for net::SocketAddrV6 {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
if serializer.is_human_readable() {
const MAX_LEN: usize = 58;
debug_assert_eq!(
MAX_LEN,
"[1001:1002:1003:1004:1005:1006:1007:1008%4294967295]:65000".len()
);
serialize_display_bounded_length!(self, MAX_LEN, serializer)
} else {
(self.ip(), self.port()).serialize(serializer)
}
}
}

I have already dug around the commit logs to see if there was a reason, but as far as I can tell it was just an oversight.

The fix is obvious and trivial, and I'm happy to do the PR. But before doing so I wanted to find out whether there is some existing mechanism to use when introducing backwards incompatible changes to serialized representations like this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant