mirror of
https://github.com/rustdesk/rustdesk-server.git
synced 2024-11-27 14:59:21 +08:00
add illumos support (#433)
This commit is contained in:
parent
e40994d62e
commit
041a603173
@ -62,10 +62,11 @@ fn new_socket(addr: std::net::SocketAddr, reuse: bool) -> Result<TcpSocket, std:
|
|||||||
std::net::SocketAddr::V6(..) => TcpSocket::new_v6()?,
|
std::net::SocketAddr::V6(..) => TcpSocket::new_v6()?,
|
||||||
};
|
};
|
||||||
if reuse {
|
if reuse {
|
||||||
// windows has no reuse_port, but it's reuse_address
|
// windows has no reuse_port, but its reuse_address
|
||||||
// almost equals to unix's reuse_port + reuse_address,
|
// almost equals to unix's reuse_port + reuse_address,
|
||||||
// though may introduce nondeterministic behavior
|
// though may introduce nondeterministic behavior.
|
||||||
#[cfg(unix)]
|
// illumos has no support for SO_REUSEPORT
|
||||||
|
#[cfg(all(unix, not(target_os = "illumos")))]
|
||||||
socket.set_reuseport(true)?;
|
socket.set_reuseport(true)?;
|
||||||
socket.set_reuseaddr(true)?;
|
socket.set_reuseaddr(true)?;
|
||||||
}
|
}
|
||||||
@ -263,10 +264,11 @@ pub async fn new_listener<T: ToSocketAddrs>(addr: T, reuse: bool) -> ResultType<
|
|||||||
pub async fn listen_any(port: u16, reuse: bool) -> ResultType<TcpListener> {
|
pub async fn listen_any(port: u16, reuse: bool) -> ResultType<TcpListener> {
|
||||||
if let Ok(mut socket) = TcpSocket::new_v6() {
|
if let Ok(mut socket) = TcpSocket::new_v6() {
|
||||||
if reuse {
|
if reuse {
|
||||||
// windows has no reuse_port, but it's reuse_address
|
// windows has no reuse_port, but its reuse_address
|
||||||
// almost equals to unix's reuse_port + reuse_address,
|
// almost equals to unix's reuse_port + reuse_address,
|
||||||
// though may introduce nondeterministic behavior
|
// though may introduce nondeterministic behavior.
|
||||||
#[cfg(unix)]
|
// illumos has no support for SO_REUSEPORT
|
||||||
|
#[cfg(all(unix, not(target_os = "illumos")))]
|
||||||
socket.set_reuseport(true).ok();
|
socket.set_reuseport(true).ok();
|
||||||
socket.set_reuseaddr(true).ok();
|
socket.set_reuseaddr(true).ok();
|
||||||
}
|
}
|
||||||
|
@ -20,10 +20,11 @@ fn new_socket(addr: SocketAddr, reuse: bool, buf_size: usize) -> Result<Socket,
|
|||||||
SocketAddr::V6(..) => Socket::new(Domain::ipv6(), Type::dgram(), None),
|
SocketAddr::V6(..) => Socket::new(Domain::ipv6(), Type::dgram(), None),
|
||||||
}?;
|
}?;
|
||||||
if reuse {
|
if reuse {
|
||||||
// windows has no reuse_port, but it's reuse_address
|
// windows has no reuse_port, but its reuse_address
|
||||||
// almost equals to unix's reuse_port + reuse_address,
|
// almost equals to unix's reuse_port + reuse_address,
|
||||||
// though may introduce nondeterministic behavior
|
// though may introduce nondeterministic behavior.
|
||||||
#[cfg(unix)]
|
// illumos has no support for SO_REUSEPORT
|
||||||
|
#[cfg(all(unix, not(target_os = "illumos")))]
|
||||||
socket.set_reuse_port(true)?;
|
socket.set_reuse_port(true)?;
|
||||||
socket.set_reuse_address(true)?;
|
socket.set_reuse_address(true)?;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user