Closed glts closed 4 years ago
Hi @glts, so you'd find the following From implementations useful? Would you like to fork and impl these yourself then give me a pull request when ready?
From<IpAddr> for IpNet
From<Ipv4Addr> for Ipv4Net
From<Ipv6Addr> for Ipv6Net
@krisprice Exactly. This is in a configuration context where administrators may declare addresses from certain networks as trusted. The inputs I would like to support are both CIDR networks (127.0.0.1/8) and IP addresses (127.0.0.1; probably more familiar to most administrators).
I’m not yet familiar with the ipnet codebase, but will try to send a pull request later, thank you.
I have recently needed conversion of exact
IpAddr
s to CIDR network addresses, and found that ipnet does not support conversion from anIpAddr
to anIpNet
.Since that conversion is as far as I understand trivial and would always succeed (call
Ipv{4,6}Net::new
with address and max prefix length [?]), I was wondering if you would consider providing that conversion inIpNet
?This would of course be purely a convenience feature, but perhaps a useful one. Thank you!