mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-21 03:21:08 +03:00
Detect unspecified IP and use TCP conn IP instead
This commit is contained in:
parent
ad07866275
commit
15705b3fa1
1 changed files with 4 additions and 2 deletions
|
@ -172,14 +172,16 @@ impl Handshake {
|
|||
fn extract_ip(advertised: &SocketAddr, conn: &TcpStream) -> SocketAddr {
|
||||
match advertised {
|
||||
&SocketAddr::V4(v4sock) => {
|
||||
if v4sock.ip().is_loopback() {
|
||||
let ip = v4sock.ip();
|
||||
if ip.is_loopback() || ip.is_unspecified() {
|
||||
if let Ok(addr) = conn.peer_addr() {
|
||||
return SocketAddr::new(addr.ip(), advertised.port());
|
||||
}
|
||||
}
|
||||
}
|
||||
&SocketAddr::V6(v6sock) => {
|
||||
if v6sock.ip().is_loopback() {
|
||||
let ip = v6sock.ip();
|
||||
if ip.is_loopback() || ip.is_unspecified() {
|
||||
if let Ok(addr) = conn.peer_addr() {
|
||||
return SocketAddr::new(addr.ip(), advertised.port());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue