Conditionally compile peer credentials feature for supported platforms
This commit is contained in:
parent
fa697dfa81
commit
72eef6168f
@ -443,6 +443,15 @@ pub fn peer_addr(&self) -> io::Result<SocketAddr> {
|
||||
/// }
|
||||
/// ```
|
||||
#[unstable(feature = "peer_credentials_unix_socket", issue = "42839", reason = "unstable")]
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "dragonfly",
|
||||
target_os = "freebsd",
|
||||
target_os = "ios",
|
||||
target_os = "macos",
|
||||
target_os = "openbsd"
|
||||
))]
|
||||
pub fn peer_cred(&self) -> io::Result<UCred> {
|
||||
ucred::peer_cred(self)
|
||||
}
|
||||
|
@ -2,6 +2,15 @@
|
||||
use libc::{getegid, geteuid};
|
||||
|
||||
#[test]
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "dragonfly",
|
||||
target_os = "freebsd",
|
||||
target_os = "ios",
|
||||
target_os = "macos",
|
||||
target_os = "openbsd"
|
||||
))]
|
||||
fn test_socket_pair() {
|
||||
// Create two connected sockets and get their peer credentials. They should be equal.
|
||||
let (sock_a, sock_b) = UnixStream::pair().unwrap();
|
||||
|
Loading…
Reference in New Issue
Block a user