aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock2
-rw-r--r--Cargo.toml2
-rw-r--r--debian/changelog4
-rw-r--r--libs/hbb_common/src/tcp.rs10
-rw-r--r--src/hbbr.rs2
-rw-r--r--src/relay_server.rs2
-rw-r--r--src/rendezvous_server.rs6
7 files changed, 20 insertions, 8 deletions
diff --git a/Cargo.lock b/Cargo.lock
index bb7082e..6ff99fc 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -779,7 +779,7 @@ dependencies = [
[[package]]
name = "hbbs"
-version = "1.1.11"
+version = "1.1.11-1"
dependencies = [
"async-speed-limit",
"async-trait",
diff --git a/Cargo.toml b/Cargo.toml
index 5513108..830f1d2 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "hbbs"
-version = "1.1.11"
+version = "1.1.11-1"
authors = ["rustdesk <[email protected]>"]
edition = "2021"
build = "build.rs"
diff --git a/debian/changelog b/debian/changelog
index e1fcadc..9058df0 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,7 @@
+rustdesk-server (1.1.11-1) UNRELEASED; urgency=medium
+ * set reuse port to make restart friendly
+ * revert hbbr `-k` to not ruin back-compatibility
+
rustdesk-server (1.1.11) UNRELEASED; urgency=medium
* change -k to default '-', so you need not to set -k any more
diff --git a/libs/hbb_common/src/tcp.rs b/libs/hbb_common/src/tcp.rs
index f574e83..046d901 100644
--- a/libs/hbb_common/src/tcp.rs
+++ b/libs/hbb_common/src/tcp.rs
@@ -260,8 +260,16 @@ pub async fn new_listener<T: ToSocketAddrs>(addr: T, reuse: bool) -> ResultType<
}
}
-pub async fn listen_any(port: u16) -> ResultType<TcpListener> {
+pub async fn listen_any(port: u16, reuse: bool) -> ResultType<TcpListener> {
if let Ok(mut socket) = TcpSocket::new_v6() {
+ if reuse {
+ // windows has no reuse_port, but it's reuse_address
+ // almost equals to unix's reuse_port + reuse_address,
+ // though may introduce nondeterministic behavior
+ #[cfg(unix)]
+ socket.set_reuseport(true).ok();
+ socket.set_reuseaddr(true).ok();
+ }
#[cfg(unix)]
{
use std::os::unix::io::{FromRawFd, IntoRawFd};
diff --git a/src/hbbr.rs b/src/hbbr.rs
index 49d449c..4c8a784 100644
--- a/src/hbbr.rs
+++ b/src/hbbr.rs
@@ -39,7 +39,7 @@ fn main() -> ResultType<()> {
matches.value_of("port").unwrap_or(&port.to_string()),
matches
.value_of("key")
- .unwrap_or(&std::env::var("KEY").unwrap_or("-".to_owned())),
+ .unwrap_or(&std::env::var("KEY").unwrap_or_default()),
)?;
Ok(())
}
diff --git a/src/relay_server.rs b/src/relay_server.rs
index e042c23..b55d544 100644
--- a/src/relay_server.rs
+++ b/src/relay_server.rs
@@ -85,7 +85,7 @@ pub async fn start(port: &str, key: &str) -> ResultType<()> {
let main_task = async move {
loop {
log::info!("Start");
- io_loop(listen_any(port).await?, listen_any(port2).await?, &key).await;
+ io_loop(listen_any(port, true).await?, listen_any(port2, true).await?, &key).await;
}
};
let listen_signal = crate::common::listen_signal();
diff --git a/src/rendezvous_server.rs b/src/rendezvous_server.rs
index 0c0d107..bb99ee0 100644
--- a/src/rendezvous_server.rs
+++ b/src/rendezvous_server.rs
@@ -1294,19 +1294,19 @@ async fn send_rk_res(
async fn create_udp_listener(port: i32, rmem: usize) -> ResultType<FramedSocket> {
let addr = SocketAddr::new(IpAddr::V6(Ipv6Addr::UNSPECIFIED), port as _);
- if let Ok(s) = FramedSocket::new_reuse(&addr, false, rmem).await {
+ if let Ok(s) = FramedSocket::new_reuse(&addr, true, rmem).await {
log::debug!("listen on udp {:?}", s.local_addr());
return Ok(s);
}
let addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::UNSPECIFIED), port as _);
- let s = FramedSocket::new_reuse(&addr, false, rmem).await?;
+ let s = FramedSocket::new_reuse(&addr, true, rmem).await?;
log::debug!("listen on udp {:?}", s.local_addr());
Ok(s)
}
#[inline]
async fn create_tcp_listener(port: i32) -> ResultType<TcpListener> {
- let s = listen_any(port as _).await?;
+ let s = listen_any(port as _, true).await?;
log::debug!("listen on tcp {:?}", s.local_addr());
Ok(s)
}