diff --git a/src/socket.rs b/src/socket.rs index b0c2ad75..b8f83b99 100644 --- a/src/socket.rs +++ b/src/socket.rs @@ -5,7 +5,6 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. - use std::fmt; use std::io::{self, Read, Write}; #[cfg(not(target_os = "redox"))] @@ -18,11 +17,11 @@ use std::net::{self, Ipv4Addr, Shutdown}; use std::os::unix::io::{FromRawFd, IntoRawFd}; #[cfg(windows)] use std::os::windows::io::{FromRawSocket, IntoRawSocket}; +use std::time::Duration; #[cfg(windows)] use windows_sys::Win32::Networking::WinSock::{ - IP6T_SO_ORIGINAL_DST, SOL_IP, SO_ORIGINAL_DST, SOCKET_ERROR + IP6T_SO_ORIGINAL_DST, SOCKET_ERROR, SOL_IP, SO_ORIGINAL_DST, }; -use std::time::Duration; use crate::sys::{self, c_int, getsockopt, setsockopt, Bool}; #[cfg(all(unix, not(target_os = "redox")))] @@ -31,8 +30,8 @@ use crate::{Domain, Protocol, SockAddr, TcpKeepalive, Type}; #[cfg(not(target_os = "redox"))] use crate::{MaybeUninitSlice, MsgHdr, RecvFlags}; -#[cfg(all(feature = "all", windows))] -#[cfg_attr(docsrs, doc(cfg(all(windows, feature = "all"))))] +#[cfg(windows)] +#[cfg_attr(docsrs, doc(cfg(windows)))] /// Helper macro to execute a system call that returns an `io::Result`. macro_rules! syscall { ($fn: ident ( $($arg: expr),* $(,)* ), $err_test: path, $err_value: expr) => {{ @@ -49,16 +48,17 @@ macro_rules! syscall { #[cfg(all( feature = "all", any( - target_os = "android", - target_os = "dragonfly", - target_os = "freebsd", - target_os = "fuchsia", - target_os = "hurd", - target_os = "illumos", - target_os = "linux", - target_os = "netbsd", - target_os = "openbsd", -)))] + target_os = "android", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "fuchsia", + target_os = "hurd", + target_os = "illumos", + target_os = "linux", + target_os = "netbsd", + target_os = "openbsd", + ) +))] /// Helper macro to execute a system call that returns an `io::Result`. macro_rules! syscall { ($fn: ident ( $($arg: expr),* $(,)* ) ) => {{ @@ -2307,7 +2307,7 @@ impl Socket { .map(|(_, addr)| addr) } - /// Get the value for the `SO_ORIGINAL_DST` option on this socket. + /// Get the value for the `SO_ORIGINAL_DST` option on this socket. /// Only valid for sockets in accepting mode. /// /// Note: if using this function in a proxy context, you must query the @@ -2315,8 +2315,8 @@ impl Socket { /// created by your proxy in order for any OS level firewall rules to be /// applied. Read more in the Windows bind and connect redirection /// [documentation](https://learn.microsoft.com/en-us/windows-hardware/drivers/network/using-bind-or-connect-redirection). - #[cfg(all(feature = "all", target_os = "windows"))] - #[cfg_attr(docsrs, doc(cfg(all(windows, feature = "all"))))] + #[cfg(windows)] + #[cfg_attr(docsrs, doc(cfg(windows)))] pub fn original_dst(&self) -> io::Result { unsafe { SockAddr::try_init(|storage, len| { @@ -2344,8 +2344,8 @@ impl Socket { /// created by your proxy in order for any OS level firewall rules to be /// applied. Read more in the Windows bind and connect redirection /// [documentation](https://learn.microsoft.com/en-us/windows-hardware/drivers/network/using-bind-or-connect-redirection). - #[cfg(all(feature = "all", target_os = "windows"))] - #[cfg_attr(docsrs, doc(cfg(all(windows, feature = "all"))))] + #[cfg(windows)] + #[cfg_attr(docsrs, doc(cfg(windows)))] pub fn original_dst_ipv6(&self) -> io::Result { unsafe { SockAddr::try_init(|storage, len| { diff --git a/src/sys/windows.rs b/src/sys/windows.rs index a1839e0e..11f2b7b0 100644 --- a/src/sys/windows.rs +++ b/src/sys/windows.rs @@ -20,14 +20,14 @@ use std::time::{Duration, Instant}; use std::{process, ptr, slice}; use windows_sys::Win32::Foundation::{SetHandleInformation, HANDLE, HANDLE_FLAG_INHERIT}; +#[cfg(feature = "all")] +use windows_sys::Win32::Networking::WinSock::SO_PROTOCOL_INFOW; use windows_sys::Win32::Networking::WinSock::{ self, tcp_keepalive, FIONBIO, IN6_ADDR, IN6_ADDR_0, INVALID_SOCKET, IN_ADDR, IN_ADDR_0, POLLERR, POLLHUP, POLLRDNORM, POLLWRNORM, SD_BOTH, SD_RECEIVE, SD_SEND, SIO_KEEPALIVE_VALS, SOCKET_ERROR, WSABUF, WSAEMSGSIZE, WSAESHUTDOWN, WSAPOLLFD, WSAPROTOCOL_INFOW, WSA_FLAG_NO_HANDLE_INHERIT, WSA_FLAG_OVERLAPPED, }; -#[cfg(feature = "all")] -use windows_sys::Win32::Networking::WinSock::SO_PROTOCOL_INFOW; use windows_sys::Win32::System::Threading::INFINITE; use crate::{MsgHdr, RecvFlags, SockAddr, TcpKeepalive, Type};