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

Replace From<Ip*Addr> for IpNet with explicit constructors #5687

Closed
jgallagher opened this issue May 2, 2024 · 0 comments · Fixed by #5711
Closed

Replace From<Ip*Addr> for IpNet with explicit constructors #5687

jgallagher opened this issue May 2, 2024 · 0 comments · Fixed by #5711

Comments

@jgallagher
Copy link
Contributor

After running into a mistake where we converted a raw IP into a /128 (when it should have been a /56), fixed in #5668, we filed an upstream request (achanda/ipnetwork#190) to remove the From impl to discourage accidental misuse by requiring a more explicit constructor. I just noticed we also have an IpNet type that implements these same conversions:

impl From<Ipv4Addr> for IpNet {
fn from(n: Ipv4Addr) -> IpNet {
IpNet::V4(Ipv4Net(ipnetwork::Ipv4Network::from(n)))
}
}
(and the subsequent conversions from Ipv6Addr and IpAddr a little below that). We should also remove these and provide explicit constructors instead, I think.

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

Successfully merging a pull request may close this issue.

1 participant