mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-21 03:21:08 +03:00
Attempt to read ipv4-mapped ipv6 to ipv4 if possible (#3221)
This commit is contained in:
parent
65e4f7efe0
commit
b400a4b1cf
1 changed files with 8 additions and 6 deletions
|
@ -143,13 +143,15 @@ impl Readable for PeerAddr {
|
|||
))))
|
||||
} else {
|
||||
let ip = try_iter_map_vec!(0..8, |_| reader.read_u16());
|
||||
let ipv6 = Ipv6Addr::new(ip[0], ip[1], ip[2], ip[3], ip[4], ip[5], ip[6], ip[7]);
|
||||
let port = reader.read_u16()?;
|
||||
Ok(PeerAddr(SocketAddr::V6(SocketAddrV6::new(
|
||||
Ipv6Addr::new(ip[0], ip[1], ip[2], ip[3], ip[4], ip[5], ip[6], ip[7]),
|
||||
port,
|
||||
0,
|
||||
0,
|
||||
))))
|
||||
if let Some(ipv4) = ipv6.to_ipv4() {
|
||||
Ok(PeerAddr(SocketAddr::V4(SocketAddrV4::new(ipv4, port))))
|
||||
} else {
|
||||
Ok(PeerAddr(SocketAddr::V6(SocketAddrV6::new(
|
||||
ipv6, port, 0, 0,
|
||||
))))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue