Skip to content

Commit 7bf90ad

Browse files
Run the clippy and tests
1 parent e28998f commit 7bf90ad

File tree

2 files changed

+13
-20
lines changed

2 files changed

+13
-20
lines changed

src/socks/v4.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ fn read_response(socket: &mut TcpStream) -> io::Result<SocketAddrV4> {
1919
match response.read_u8()? {
2020
90 => {}
2121
91 => {
22-
return Err(io::Error::new(
23-
io::ErrorKind::Other,
22+
return Err(io::Error::other(
2423
"request rejected or failed",
2524
))
2625
}

src/socks/v5.rs

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ fn read_addr<R: Read>(socket: &mut R) -> io::Result<TargetAddr> {
3737
ip, port, 0, 0,
3838
))))
3939
}
40-
_ => Err(io::Error::new(
41-
io::ErrorKind::Other,
40+
_ => Err(io::Error::other(
4241
"unsupported address type",
4342
)),
4443
}
@@ -55,34 +54,30 @@ fn read_response(socket: &mut TcpStream) -> io::Result<TargetAddr> {
5554
match socket.read_u8()? {
5655
0 => {}
5756
1 => {
58-
return Err(io::Error::new(
59-
io::ErrorKind::Other,
57+
return Err(io::Error::other(
6058
"general SOCKS server failure",
6159
))
6260
}
6361
2 => {
64-
return Err(io::Error::new(
65-
io::ErrorKind::Other,
62+
return Err(io::Error::other(
6663
"connection not allowed by ruleset",
6764
))
6865
}
69-
3 => return Err(io::Error::new(io::ErrorKind::Other, "network unreachable")),
70-
4 => return Err(io::Error::new(io::ErrorKind::Other, "host unreachable")),
71-
5 => return Err(io::Error::new(io::ErrorKind::Other, "connection refused")),
72-
6 => return Err(io::Error::new(io::ErrorKind::Other, "TTL expired")),
66+
3 => return Err(io::Error::other("network unreachable")),
67+
4 => return Err(io::Error::other("host unreachable")),
68+
5 => return Err(io::Error::other("connection refused")),
69+
6 => return Err(io::Error::other("TTL expired")),
7370
7 => {
74-
return Err(io::Error::new(
75-
io::ErrorKind::Other,
71+
return Err(io::Error::other(
7672
"command not supported",
7773
))
7874
}
7975
8 => {
80-
return Err(io::Error::new(
81-
io::ErrorKind::Other,
76+
return Err(io::Error::other(
8277
"address kind not supported",
8378
))
8479
}
85-
_ => return Err(io::Error::new(io::ErrorKind::Other, "unknown error")),
80+
_ => return Err(io::Error::other("unknown error")),
8681
}
8782

8883
if socket.read_u8()? != 0 {
@@ -227,14 +222,13 @@ impl Socks5Stream {
227222
}
228223

229224
if selected_method == 0xff {
230-
return Err(io::Error::new(
231-
io::ErrorKind::Other,
225+
return Err(io::Error::other(
232226
"no acceptable auth methods",
233227
));
234228
}
235229

236230
if selected_method != auth.id() && selected_method != Authentication::None.id() {
237-
return Err(io::Error::new(io::ErrorKind::Other, "unknown auth method"));
231+
return Err(io::Error::other("unknown auth method"));
238232
}
239233

240234
match *auth {

0 commit comments

Comments
 (0)