mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-21 03:21:08 +03:00
Convert ipv4-mapped ipv6 when accepting peer (#3225)
This commit is contained in:
parent
b400a4b1cf
commit
053415ddf8
1 changed files with 15 additions and 2 deletions
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{self, Read};
|
use std::io::{self, Read};
|
||||||
use std::net::{Shutdown, SocketAddr, TcpListener, TcpStream};
|
use std::net::{IpAddr, Shutdown, SocketAddr, SocketAddrV4, TcpListener, TcpStream};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::thread;
|
use std::thread;
|
||||||
|
@ -92,7 +92,20 @@ impl Server {
|
||||||
// we do not want.
|
// we do not want.
|
||||||
stream.set_nonblocking(false)?;
|
stream.set_nonblocking(false)?;
|
||||||
|
|
||||||
let peer_addr = PeerAddr(peer_addr);
|
let mut peer_addr = PeerAddr(peer_addr);
|
||||||
|
|
||||||
|
// attempt to see if it an ipv4-mapped ipv6
|
||||||
|
// if yes convert to ipv4
|
||||||
|
if peer_addr.0.is_ipv6() {
|
||||||
|
if let IpAddr::V6(ipv6) = peer_addr.0.ip() {
|
||||||
|
if let Some(ipv4) = ipv6.to_ipv4() {
|
||||||
|
peer_addr = PeerAddr(SocketAddr::V4(SocketAddrV4::new(
|
||||||
|
ipv4,
|
||||||
|
peer_addr.0.port(),
|
||||||
|
)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if self.check_undesirable(&stream) {
|
if self.check_undesirable(&stream) {
|
||||||
// Shutdown the incoming TCP connection if it is not desired
|
// Shutdown the incoming TCP connection if it is not desired
|
||||||
|
|
Loading…
Reference in a new issue