Skip to content

Commit cba8420

Browse files
authored
Merge pull request #3 from rvbcldud/fix-ipv4-compatability
Changed Ipv4-compatible to Ipv4-mapped addresses
2 parents 041184c + 0816e86 commit cba8420

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ pub fn ip(name: &str, net: IpNetwork) -> Result<IpAddr> {
5353
return Err(Error::PrefixTooBig(net));
5454
}
5555
let prefix = IP6_PREFIX - IP4_PREFIX + net4.prefix();
56-
let net6 = format!("::{}/{prefix}", net4.ip()).parse::<Ipv6Network>()?;
56+
let net6 = format!("::ffff:{}/{prefix}", net4.ip()).parse::<Ipv6Network>()?;
5757
let ipv6_addr = ip6(name, net6)?.to_string();
5858
let ip_addr = ipv6_addr
59-
.strip_prefix("::")
59+
.strip_prefix("::ffff:")
6060
// This error should never happen but I'm not a fan of panicking in libraries
6161
.ok_or_else(|| Error::InvalidIpNetwork(format!("[BUG] the generated IPv6 address `{ipv6_addr}` does not start with the expected prefix `::`")))?
6262
.parse()

0 commit comments

Comments
 (0)