From 839a28a3d5c7d75dbe556832e9018e4a12ef0f21 Mon Sep 17 00:00:00 2001 From: "Sijie.Sun" Date: Thu, 21 Aug 2025 09:30:51 +0800 Subject: [PATCH] avoid panic on smoltcp socket accept (#1272) --- .github/workflows/core.yml | 11 +++++------ .github/workflows/gui.yml | 10 ++++------ .github/workflows/mobile.yml | 10 ++++------ easytier/src/gateway/tokio_smoltcp/socket.rs | 13 ++++++++----- 4 files changed, 21 insertions(+), 23 deletions(-) diff --git a/.github/workflows/core.yml b/.github/workflows/core.yml index d9e31fe..d44aee9 100644 --- a/.github/workflows/core.yml +++ b/.github/workflows/core.yml @@ -154,14 +154,13 @@ jobs: name: easytier-web-dashboard path: easytier-web/frontend/dist/ - - name: Cargo cache + - uses: Swatinem/rust-cache@v2 if: ${{ ! endsWith(matrix.TARGET, 'freebsd') }} - uses: actions/cache@v4 with: - path: | - ~/.cargo - ./target - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + # The prefix cache key, this can be changed to start a new cache manually. + # default: "v0-rust" + prefix-key: "" + - name: Setup protoc uses: arduino/setup-protoc@v3 diff --git a/.github/workflows/gui.yml b/.github/workflows/gui.yml index 146406c..5516a35 100644 --- a/.github/workflows/gui.yml +++ b/.github/workflows/gui.yml @@ -151,13 +151,11 @@ jobs: pnpm -r install pnpm -r build - - name: Cargo cache - uses: actions/cache@v4 + - uses: Swatinem/rust-cache@v2 with: - path: | - ~/.cargo - ./target - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + # The prefix cache key, this can be changed to start a new cache manually. + # default: "v0-rust" + prefix-key: "" - name: Install rust target run: bash ./.github/workflows/install_rust.sh diff --git a/.github/workflows/mobile.yml b/.github/workflows/mobile.yml index b122c41..dec7d25 100644 --- a/.github/workflows/mobile.yml +++ b/.github/workflows/mobile.yml @@ -98,13 +98,11 @@ jobs: pnpm -r install pnpm -r build - - name: Cargo cache - uses: actions/cache@v4 + - uses: Swatinem/rust-cache@v2 with: - path: | - ~/.cargo - ./target - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + # The prefix cache key, this can be changed to start a new cache manually. + # default: "v0-rust" + prefix-key: "" - name: Install rust target run: | diff --git a/easytier/src/gateway/tokio_smoltcp/socket.rs b/easytier/src/gateway/tokio_smoltcp/socket.rs index 46dc7a9..414093b 100644 --- a/easytier/src/gateway/tokio_smoltcp/socket.rs +++ b/easytier/src/gateway/tokio_smoltcp/socket.rs @@ -156,11 +156,14 @@ impl TcpStream { } let (peer_addr, local_addr) = { let socket = reactor.get_socket::(*listener.handle); - ( - // should be Some, because the state is Established - ep2sa(&socket.remote_endpoint().unwrap()), - ep2sa(&socket.local_endpoint().unwrap()), - ) + match (socket.remote_endpoint(), socket.local_endpoint()) { + (Some(remote_endpoint), Some(local_endpoint)) => ( + // should be Some, because the state is Established + ep2sa(&remote_endpoint), + ep2sa(&local_endpoint), + ), + _ => return Err(io::ErrorKind::NotConnected.into()), + } }; Ok((