diff --git a/crates/shadowsocks/src/net/sys/mod.rs b/crates/shadowsocks/src/net/sys/mod.rs index 0944f8c785f1..c45bcd6eb7c8 100644 --- a/crates/shadowsocks/src/net/sys/mod.rs +++ b/crates/shadowsocks/src/net/sys/mod.rs @@ -151,16 +151,16 @@ static IP_STACK_CAPABILITIES: Lazy = Lazy::new(|| { }; // Check IPv4 - if let Ok(_) = Socket::new(Domain::IPV4, Type::STREAM, Some(Protocol::TCP)) { + if Socket::new(Domain::IPV4, Type::STREAM, Some(Protocol::TCP)).is_ok() { caps.support_ipv4 = true; debug!("IpStackCapability support_ipv4=true"); } // Check IPv6 (::1) if let Ok(ipv6_socket) = Socket::new(Domain::IPV6, Type::STREAM, Some(Protocol::TCP)) { - if let Ok(..) = ipv6_socket.set_only_v6(true) { + if ipv6_socket.set_only_v6(true).is_ok() { let local_host = SockAddr::from(SocketAddr::new(Ipv6Addr::LOCALHOST.into(), 0)); - if let Ok(..) = ipv6_socket.bind(&local_host) { + if ipv6_socket.bind(&local_host).is_ok() { caps.support_ipv6 = true; debug!("IpStackCapability support_ipv6=true"); } @@ -168,7 +168,7 @@ static IP_STACK_CAPABILITIES: Lazy = Lazy::new(|| { } // Check IPv4-mapped-IPv6 (127.0.0.1) - if let Ok(..) = check_ipv4_mapped_ipv6_capability() { + if check_ipv4_mapped_ipv6_capability().is_ok() { caps.support_ipv4_mapped_ipv6 = true; debug!("IpStackCapability support_ipv4_mapped_ipv6=true"); } @@ -192,7 +192,7 @@ fn check_ipv4_mapped_ipv6_capability() -> io::Result<()> { return Err(io::Error::new( ErrorKind::Other, "local_addr shouldn't be an IPv4 address", - )) + )); } SocketAddr::V6(ref v6) => { if let None = v6.ip().to_ipv4_mapped() {