Skip to content

Commit daff7a5

Browse files
committed
chore(ci): add fmt and clippy checks
1 parent e7af332 commit daff7a5

File tree

4 files changed

+39
-28
lines changed

4 files changed

+39
-28
lines changed

.github/workflows/cont_integration.yml

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ on: [push, pull_request]
33
name: CI
44

55
jobs:
6-
test-fmt:
6+
test:
77
name: Test
88
runs-on: ubuntu-20.04
99
env:
@@ -16,7 +16,7 @@ jobs:
1616
- 1.63.0 # MSRV
1717
steps:
1818
- name: Checkout
19-
uses: actions/checkout@v2
19+
uses: actions/checkout@v4
2020
- name: Cache
2121
uses: actions/cache@v2
2222
with:
@@ -25,14 +25,10 @@ jobs:
2525
~/.cargo/git
2626
target
2727
key: ${{ runner.os }}-cargo-${{ github.job }}-${{ hashFiles('**/Cargo.toml','**/Cargo.lock') }}
28-
- name: Install rustup
29-
run: curl https://sh.rustup.rs -sSf | sh -s -- -y
30-
- name: Set default toolchain
31-
run: $HOME/.cargo/bin/rustup default ${{ matrix.rust }}
32-
- name: Set profile
33-
run: $HOME/.cargo/bin/rustup set profile minimal
34-
- name: Fmt
35-
run: cargo fmt -- --check --verbose
28+
- name: Install rust
29+
uses: dtolnay/rust-toolchain@stable
30+
with:
31+
toolchain: ${{ matrix.rust }}
3632
- name: Test
3733
run: cargo test --verbose --all-features
3834
- name: Setup iptables for the timeout test
@@ -46,3 +42,32 @@ jobs:
4642
- run: cargo check --verbose --no-default-features --features=proxy,use-openssl
4743
- run: cargo check --verbose --no-default-features --features=proxy,use-rustls
4844
- run: cargo check --verbose --no-default-features --features=proxy,use-rustls-ring
45+
46+
fmt:
47+
name: Rust fmt
48+
runs-on: ubuntu-latest
49+
steps:
50+
- name: Checkout
51+
uses: actions/checkout@v4
52+
- name: Install Rust toolchain
53+
uses: dtolnay/rust-toolchain@stable
54+
with:
55+
toolchain: stable
56+
components: rustfmt
57+
- name: Check fmt
58+
run: cargo fmt --all -- --config format_code_in_doc_comments=true --check
59+
60+
clippy_check:
61+
runs-on: ubuntu-latest
62+
steps:
63+
- uses: actions/checkout@v4
64+
- uses: dtolnay/rust-toolchain@stable
65+
with:
66+
toolchain: 1.78.0
67+
components: clippy
68+
- name: Rust Cache
69+
uses: Swatinem/[email protected]
70+
- uses: actions-rs/clippy-check@v1
71+
with:
72+
token: ${{ secrets.GITHUB_TOKEN }}
73+
args: --all-features --all-targets -- -D warnings

src/client.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ impl Client {
148148
/// If no prefix is specified, then `tcp://` is assumed.
149149
///
150150
/// See [Client::from_config] for more configuration options
151-
///
152151
pub fn new(url: &str) -> Result<Self, Error> {
153152
Self::from_config(url, Config::default())
154153
}

src/socks/v4.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,7 @@ impl Socks4Stream {
117117
socket.write_all(&packet)?;
118118
let proxy_addr = read_response(&mut socket)?;
119119

120-
Ok(Socks4Stream {
121-
socket,
122-
proxy_addr,
123-
})
120+
Ok(Socks4Stream { socket, proxy_addr })
124121
}
125122

126123
/// Returns the proxy-side address of the connection between the proxy and

src/socks/v5.rs

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,7 @@ impl Socks5Stream {
253253

254254
let proxy_addr = read_response(&mut socket)?;
255255

256-
Ok(Socks5Stream {
257-
socket,
258-
proxy_addr,
259-
})
256+
Ok(Socks5Stream { socket, proxy_addr })
260257
}
261258

262259
fn password_authentication(
@@ -470,10 +467,7 @@ impl Socks5Datagram {
470467
let socket = UdpSocket::bind(addr)?;
471468
socket.connect(&stream.proxy_addr)?;
472469

473-
Ok(Socks5Datagram {
474-
socket,
475-
stream,
476-
})
470+
Ok(Socks5Datagram { socket, stream })
477471
}
478472

479473
/// Like `UdpSocket::send_to`.
@@ -522,11 +516,7 @@ impl Socks5Datagram {
522516
let addr = read_addr(&mut header)?;
523517

524518
unsafe {
525-
ptr::copy(
526-
buf.as_ptr(),
527-
buf.as_mut_ptr().add(header.len()),
528-
overflow,
529-
);
519+
ptr::copy(buf.as_ptr(), buf.as_mut_ptr().add(header.len()), overflow);
530520
}
531521
buf[..header.len()].copy_from_slice(header);
532522

0 commit comments

Comments
 (0)