Skip to content

Commit a79517a

Browse files
committed
Lower log level of early EOF while handshaking
- ref #490 - Enable clippy on github action
1 parent 18db10d commit a79517a

File tree

2 files changed

+26
-54
lines changed

2 files changed

+26
-54
lines changed

.github/workflows/build-and-test.yml

Lines changed: 18 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,17 @@ on:
99
env:
1010
CARGO_TERM_COLOR: always
1111
RUSTFLAGS: "-Ctarget-feature=+aes,+ssse3"
12-
RUST_LOG: "shadowsocks=trace"
12+
RUST_LOG: "trace"
1313

1414
jobs:
15-
build-linux:
16-
runs-on: ubuntu-latest
15+
buid-test-check:
16+
strategy:
17+
matrix:
18+
platform:
19+
- ubuntu-latest
20+
- windows-latest
21+
- macos-latest
22+
runs-on: ${{ matrix.platform }}
1723

1824
steps:
1925
- uses: actions/checkout@v2
@@ -28,60 +34,19 @@ jobs:
2834
uses: actions-rs/toolchain@v1
2935
with:
3036
profile: minimal
37+
components: clippy
3138
- name: Build & Test (Default)
3239
run: cargo test --verbose --no-fail-fast
3340
- name: Build & Test (--no-default-features)
3441
run: cargo test --verbose --no-default-features --no-fail-fast
3542
- name: Build with All Features Enabled
3643
run: cargo build --verbose --features "local-redir local-dns dns-over-tls dns-over-https stream-cipher"
37-
38-
build-windows:
39-
runs-on: windows-latest
40-
41-
steps:
42-
- uses: actions/checkout@v2
43-
- uses: actions/cache@v2
44-
with:
45-
path: |
46-
~/.cargo/registry
47-
~/.cargo/git
48-
target
49-
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
50-
- name: Install Rust nightly
51-
uses: actions-rs/toolchain@v1
52-
with:
53-
profile: minimal
54-
- name: Build & Test (Default)
55-
run: cargo test --verbose --no-fail-fast
56-
- name: Build & Test (--no-default-features)
57-
run: cargo test --verbose --no-default-features --no-fail-fast
58-
- name: Build with All Features Enabled
59-
run: cargo build --verbose --features "local-dns dns-over-tls dns-over-https stream-cipher"
60-
61-
build-macos:
62-
runs-on: macos-latest
63-
64-
steps:
65-
- uses: actions/checkout@v2
66-
- name: Install GNU tar
67-
run: |
68-
brew install gnu-tar
69-
# echo "::add-path::/usr/local/opt/gnu-tar/libexec/gnubin"
70-
echo "/usr/local/opt/gnu-tar/libexec/gnubin" >> $GITHUB_PATH
71-
- uses: actions/cache@v2
72-
with:
73-
path: |
74-
~/.cargo/registry
75-
~/.cargo/git
76-
target
77-
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
78-
- name: Install Rust nightly
79-
uses: actions-rs/toolchain@v1
44+
- name: Clippy Check
45+
uses: actions-rs/clippy-check@v1
8046
with:
81-
profile: minimal
82-
- name: Build & Test (Default)
83-
run: cargo test --verbose --no-fail-fast
84-
- name: Build & Test (--no-default-features)
85-
run: cargo test --verbose --no-default-features --no-fail-fast
86-
- name: Build with All Features Enabled
87-
run: cargo build --verbose --features "local-redir local-dns dns-over-tls dns-over-https stream-cipher"
47+
name: clippy-${{ matrix.platform }}
48+
token: ${{ secrets.GITHUB_TOKEN }}
49+
args: |
50+
--all-features --verbose -- -Z macro-backtrace
51+
-W clippy::absurd_extreme_comparisons
52+
-W clippy::erasing_op

crates/shadowsocks-service/src/server/tcprelay.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use shadowsocks::{
1313
crypto::v1::CipherKind,
1414
net::{AcceptOpts, TcpStream as OutboundTcpStream},
1515
relay::{
16-
socks5::Address,
16+
socks5::{Address, Error as Socks5Error},
1717
tcprelay::{
1818
utils::{copy_from_encrypted, copy_to_encrypted},
1919
ProxyServerStream,
@@ -89,6 +89,13 @@ impl TcpServerClient {
8989
async fn serve(mut self) -> io::Result<()> {
9090
let target_addr = match Address::read_from(&mut self.stream).await {
9191
Ok(a) => a,
92+
Err(Socks5Error::IoError(ref err)) if err.kind() == ErrorKind::UnexpectedEof => {
93+
debug!(
94+
"handshake failed, received EOF before a complete target Address, peer: {}",
95+
self.peer_addr
96+
);
97+
return Ok(());
98+
}
9299
Err(err) => {
93100
// https://github.com/shadowsocks/shadowsocks-rust/issues/292
94101
//

0 commit comments

Comments
 (0)