diff --git a/tuic-client/src/socks5.rs b/tuic-client/src/socks5.rs index 1d8af58..128ab78 100644 --- a/tuic-client/src/socks5.rs +++ b/tuic-client/src/socks5.rs @@ -43,6 +43,13 @@ impl Server { let socket = Socket::from(TcpListener::bind(&cfg.server).await?.into_std()?); if let Some(dual_stack) = cfg.dual_stack { + if cfg.server.is_ipv4() && dual_stack { + return Err(Error::from(IoError::new( + ErrorKind::Unsupported, + "IPv4 socket cannot be dual stack", + ))); + } + socket.set_only_v6(!dual_stack)?; } @@ -119,6 +126,7 @@ impl Server { ); if let Some(dual_stack) = SERVER.get().unwrap().dual_stack { + // We already checked that the server address is IPv6 socket.set_only_v6(!dual_stack)?; } diff --git a/tuic-server/src/server.rs b/tuic-server/src/server.rs index 8dfa5bf..5138830 100644 --- a/tuic-server/src/server.rs +++ b/tuic-server/src/server.rs @@ -98,6 +98,13 @@ impl Server { let socket = Socket::from(StdUdpSocket::bind(cfg.server)?); if let Some(dual_stack) = cfg.dual_stack { + if cfg.server.is_ipv4() && dual_stack { + return Err(Error::from(IoError::new( + ErrorKind::Unsupported, + "IPv4 socket cannot be dual stack", + ))); + } + socket.set_only_v6(!dual_stack)?; }