diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index d6090b9a..8abaa489 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -9,11 +9,17 @@ on: env: CARGO_TERM_COLOR: always RUSTFLAGS: "-Ctarget-feature=+aes,+ssse3" - RUST_LOG: "shadowsocks=trace" + RUST_LOG: "trace" jobs: - build-linux: - runs-on: ubuntu-latest + buid-test-check: + strategy: + matrix: + platform: + - ubuntu-latest + - windows-latest + - macos-latest + runs-on: ${{ matrix.platform }} steps: - uses: actions/checkout@v2 @@ -28,60 +34,19 @@ jobs: uses: actions-rs/toolchain@v1 with: profile: minimal + components: clippy - name: Build & Test (Default) run: cargo test --verbose --no-fail-fast - name: Build & Test (--no-default-features) run: cargo test --verbose --no-default-features --no-fail-fast - name: Build with All Features Enabled run: cargo build --verbose --features "local-redir local-dns dns-over-tls dns-over-https stream-cipher" - - build-windows: - runs-on: windows-latest - - steps: - - uses: actions/checkout@v2 - - uses: actions/cache@v2 + - name: Clippy Check + uses: actions-rs/clippy-check@v1 with: - path: | - ~/.cargo/registry - ~/.cargo/git - target - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - - name: Install Rust nightly - uses: actions-rs/toolchain@v1 - with: - profile: minimal - - name: Build & Test (Default) - run: cargo test --verbose --no-fail-fast - - name: Build & Test (--no-default-features) - run: cargo test --verbose --no-default-features --no-fail-fast - - name: Build with All Features Enabled - run: cargo build --verbose --features "local-dns dns-over-tls dns-over-https stream-cipher" - - build-macos: - runs-on: macos-latest - - steps: - - uses: actions/checkout@v2 - - name: Install GNU tar - run: | - brew install gnu-tar - # echo "::add-path::/usr/local/opt/gnu-tar/libexec/gnubin" - echo "/usr/local/opt/gnu-tar/libexec/gnubin" >> $GITHUB_PATH - - uses: actions/cache@v2 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - target - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - - name: Install Rust nightly - uses: actions-rs/toolchain@v1 - with: - profile: minimal - - name: Build & Test (Default) - run: cargo test --verbose --no-fail-fast - - name: Build & Test (--no-default-features) - run: cargo test --verbose --no-default-features --no-fail-fast - - name: Build with All Features Enabled - run: cargo build --verbose --features "local-redir local-dns dns-over-tls dns-over-https stream-cipher" + name: clippy-${{ matrix.platform }} + token: ${{ secrets.GITHUB_TOKEN }} + args: | + --all-features --verbose -- -Z macro-backtrace + -W clippy::absurd_extreme_comparisons + -W clippy::erasing_op diff --git a/crates/shadowsocks-service/src/server/tcprelay.rs b/crates/shadowsocks-service/src/server/tcprelay.rs index f54aea84..9e7d79af 100644 --- a/crates/shadowsocks-service/src/server/tcprelay.rs +++ b/crates/shadowsocks-service/src/server/tcprelay.rs @@ -13,7 +13,7 @@ use shadowsocks::{ crypto::v1::CipherKind, net::{AcceptOpts, TcpStream as OutboundTcpStream}, relay::{ - socks5::Address, + socks5::{Address, Error as Socks5Error}, tcprelay::{ utils::{copy_from_encrypted, copy_to_encrypted}, ProxyServerStream, @@ -89,6 +89,13 @@ impl TcpServerClient { async fn serve(mut self) -> io::Result<()> { let target_addr = match Address::read_from(&mut self.stream).await { Ok(a) => a, + Err(Socks5Error::IoError(ref err)) if err.kind() == ErrorKind::UnexpectedEof => { + debug!( + "handshake failed, received EOF before a complete target Address, peer: {}", + self.peer_addr + ); + return Ok(()); + } Err(err) => { // https://github.com/shadowsocks/shadowsocks-rust/issues/292 //