Skip to content

Commit 0c5ae27

Browse files
fix: updated socks timeout builder logic
1 parent 79f6a7d commit 0c5ae27

File tree

2 files changed

+7
-31
lines changed

2 files changed

+7
-31
lines changed

src/socks/v4.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,7 @@ fn read_response(socket: &mut TcpStream) -> io::Result<SocketAddrV4> {
1818

1919
match response.read_u8()? {
2020
90 => {}
21-
91 => {
22-
return Err(io::Error::other(
23-
"request rejected or failed",
24-
))
25-
}
21+
91 => return Err(io::Error::other("request rejected or failed")),
2622
92 => {
2723
return Err(io::Error::new(
2824
io::ErrorKind::PermissionDenied,

src/socks/v5.rs

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ fn read_addr<R: Read>(socket: &mut R) -> io::Result<TargetAddr> {
3737
ip, port, 0, 0,
3838
))))
3939
}
40-
_ => Err(io::Error::other(
41-
"unsupported address type",
42-
)),
40+
_ => Err(io::Error::other("unsupported address type")),
4341
}
4442
}
4543

@@ -53,30 +51,14 @@ fn read_response(socket: &mut TcpStream) -> io::Result<TargetAddr> {
5351

5452
match socket.read_u8()? {
5553
0 => {}
56-
1 => {
57-
return Err(io::Error::other(
58-
"general SOCKS server failure",
59-
))
60-
}
61-
2 => {
62-
return Err(io::Error::other(
63-
"connection not allowed by ruleset",
64-
))
65-
}
54+
1 => return Err(io::Error::other("general SOCKS server failure")),
55+
2 => return Err(io::Error::other("connection not allowed by ruleset")),
6656
3 => return Err(io::Error::other("network unreachable")),
6757
4 => return Err(io::Error::other("host unreachable")),
6858
5 => return Err(io::Error::other("connection refused")),
6959
6 => return Err(io::Error::other("TTL expired")),
70-
7 => {
71-
return Err(io::Error::other(
72-
"command not supported",
73-
))
74-
}
75-
8 => {
76-
return Err(io::Error::other(
77-
"address kind not supported",
78-
))
79-
}
60+
7 => return Err(io::Error::other("command not supported")),
61+
8 => return Err(io::Error::other("address kind not supported")),
8062
_ => return Err(io::Error::other("unknown error")),
8163
}
8264

@@ -222,9 +204,7 @@ impl Socks5Stream {
222204
}
223205

224206
if selected_method == 0xff {
225-
return Err(io::Error::other(
226-
"no acceptable auth methods",
227-
));
207+
return Err(io::Error::other("no acceptable auth methods"));
228208
}
229209

230210
if selected_method != auth.id() && selected_method != Authentication::None.id() {

0 commit comments

Comments
 (0)