diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 7aee8592..af094a4a 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -174,12 +174,12 @@ jobs: fail-fast: false matrix: job: - - { os: "linux", name: "amd64" } - - { os: "linux", name: "arm64v8" } - - { os: "linux", name: "armv7" } - - { os: "linux", name: "i386" } - - { os: "linux", name: "amd64fb" } - - { os: "windows", name: "x86_64" } + - { os: "linux", name: "amd64", suffix: "" } + - { os: "linux", name: "arm64v8", suffix: "" } + - { os: "linux", name: "armv7", suffix: "" } + - { os: "linux", name: "i386", suffix: "" } + - { os: "linux", name: "amd64fb", suffix: "" } + - { os: "windows", name: "x86_64", suffix: "-unsigned" } steps: @@ -196,14 +196,14 @@ jobs: run: | sudo apt update DEBIAN_FRONTEND=noninteractive sudo apt install -y zip - zip ${{ matrix.job.name }}/rustdesk-server-${{ matrix.job.os }}-${{ matrix.job.name }}.zip ${{ matrix.job.name }}/* + zip ${{ matrix.job.name }}/rustdesk-server-${{ matrix.job.os }}-${{ matrix.job.name }}${{ matrix.job.suffix }}.zip ${{ matrix.job.name }}/* - name: Create Release (${{ matrix.job.os }} - (${{ matrix.job.name }}) uses: softprops/action-gh-release@v1 with: prerelease: false tag_name: nightly - files: ${{ matrix.job.name }}/rustdesk-server-${{ matrix.job.os }}-${{ matrix.job.name }}.zip + files: ${{ matrix.job.name }}/rustdesk-server-${{ matrix.job.os }}-${{ matrix.job.name }}${{ matrix.job.suffix }}.zip # docker build and push of single-arch images docker: @@ -262,11 +262,12 @@ jobs: echo "MAJOR_TAG=$M" >> $GITHUB_ENV - name: Build and push Docker image - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v5 with: context: "./docker" platforms: ${{ matrix.job.docker_platform }} push: true + provenance: false build-args: | S6_ARCH=${{ matrix.job.s6_platform }} tags: | @@ -382,11 +383,12 @@ jobs: echo "MAJOR_TAG=$M" >> $GITHUB_ENV - name: Build and push Docker image - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v5 with: context: "./docker-classic" platforms: ${{ matrix.job.docker_platform }} push: true + provenance: false tags: | ${{ secrets.DOCKER_IMAGE_CLASSIC }}:${{ env.LATEST_TAG }}-${{ matrix.job.name }} ${{ secrets.DOCKER_IMAGE_CLASSIC }}:${{ env.GIT_TAG }}-${{ matrix.job.name }} diff --git a/Cargo.lock b/Cargo.lock index f62e537c..6ff99fcd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -779,7 +779,7 @@ dependencies = [ [[package]] name = "hbbs" -version = "1.1.10-3" +version = "1.1.11-1" dependencies = [ "async-speed-limit", "async-trait", diff --git a/Cargo.toml b/Cargo.toml index f7febcea..830f1d22 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hbbs" -version = "1.1.10-3" +version = "1.1.11-1" authors = ["rustdesk "] edition = "2021" build = "build.rs" diff --git a/debian/changelog b/debian/changelog index e76d68a7..9058df0e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +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 + rustdesk-server (1.1.10-3) UNRELEASED; urgency=medium * fix on -2 diff --git a/libs/hbb_common/src/tcp.rs b/libs/hbb_common/src/tcp.rs index f574e830..046d9012 100644 --- a/libs/hbb_common/src/tcp.rs +++ b/libs/hbb_common/src/tcp.rs @@ -260,8 +260,16 @@ pub async fn new_listener(addr: T, reuse: bool) -> ResultType< } } -pub async fn listen_any(port: u16) -> ResultType { +pub async fn listen_any(port: u16, reuse: bool) -> ResultType { 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/main.rs b/src/main.rs index 36233ee3..902fc1ee 100644 --- a/src/main.rs +++ b/src/main.rs @@ -31,6 +31,6 @@ fn main() -> ResultType<()> { } let rmem = get_arg("rmem").parse::().unwrap_or(RMEM); let serial: i32 = get_arg("serial").parse().unwrap_or(0); - RendezvousServer::start(port, serial, &get_arg("key"), rmem)?; + RendezvousServer::start(port, serial, &get_arg_or("key", "-".to_owned()), rmem)?; Ok(()) } diff --git a/src/relay_server.rs b/src/relay_server.rs index e042c235..b55d5444 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 0c0d1075..3449e751 100644 --- a/src/rendezvous_server.rs +++ b/src/rendezvous_server.rs @@ -1182,14 +1182,11 @@ impl RendezvousServer { out_sk = sk; if !key.is_empty() { key = pk; - } else { - std::env::set_var("KEY_FOR_API", pk); } } if !key.is_empty() { log::info!("Key: {}", key); - std::env::set_var("KEY_FOR_API", key.clone()); } (key, out_sk) } @@ -1294,19 +1291,19 @@ async fn send_rk_res( async fn create_udp_listener(port: i32, rmem: usize) -> ResultType { 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 { - 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) }