Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,9 @@ mod tests {
let now = Instant::now();
let client = Client::from_config(
&endpoint,
crate::config::ConfigBuilder::new().timeout(Some(5)).build(),
crate::config::ConfigBuilder::new()
.timeout(Some(Duration::from_secs(5)))
.build(),
);
let elapsed = now.elapsed();

Expand Down
4 changes: 2 additions & 2 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ impl ConfigBuilder {
}

/// Sets the timeout
pub fn timeout(mut self, timeout: Option<u8>) -> Self {
self.config.timeout = timeout.map(|t| Duration::from_secs(t as u64));
pub fn timeout(mut self, timeout: Option<Duration>) -> Self {
self.config.timeout = timeout;
self
}

Expand Down
2 changes: 1 addition & 1 deletion src/raw_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1249,7 +1249,7 @@ mod test {
let client = RawClient::new(get_test_server(), None).unwrap();

let resp = client.relay_fee().unwrap();
assert_eq!(resp, 0.00001);
assert_eq!(resp, 0.000001);
}

#[test]
Expand Down
7 changes: 1 addition & 6 deletions src/socks/v4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,7 @@ fn read_response(socket: &mut TcpStream) -> io::Result<SocketAddrV4> {

match response.read_u8()? {
90 => {}
91 => {
return Err(io::Error::new(
io::ErrorKind::Other,
"request rejected or failed",
))
}
91 => return Err(io::Error::other("request rejected or failed")),
92 => {
return Err(io::Error::new(
io::ErrorKind::PermissionDenied,
Expand Down
50 changes: 12 additions & 38 deletions src/socks/v5.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@ fn read_addr<R: Read>(socket: &mut R) -> io::Result<TargetAddr> {
ip, port, 0, 0,
))))
}
_ => Err(io::Error::new(
io::ErrorKind::Other,
"unsupported address type",
)),
_ => Err(io::Error::other("unsupported address type")),
}
}

Expand All @@ -54,35 +51,15 @@ fn read_response(socket: &mut TcpStream) -> io::Result<TargetAddr> {

match socket.read_u8()? {
0 => {}
1 => {
return Err(io::Error::new(
io::ErrorKind::Other,
"general SOCKS server failure",
))
}
2 => {
return Err(io::Error::new(
io::ErrorKind::Other,
"connection not allowed by ruleset",
))
}
3 => return Err(io::Error::new(io::ErrorKind::Other, "network unreachable")),
4 => return Err(io::Error::new(io::ErrorKind::Other, "host unreachable")),
5 => return Err(io::Error::new(io::ErrorKind::Other, "connection refused")),
6 => return Err(io::Error::new(io::ErrorKind::Other, "TTL expired")),
7 => {
return Err(io::Error::new(
io::ErrorKind::Other,
"command not supported",
))
}
8 => {
return Err(io::Error::new(
io::ErrorKind::Other,
"address kind not supported",
))
}
_ => return Err(io::Error::new(io::ErrorKind::Other, "unknown error")),
1 => return Err(io::Error::other("general SOCKS server failure")),
2 => return Err(io::Error::other("connection not allowed by ruleset")),
3 => return Err(io::Error::other("network unreachable")),
4 => return Err(io::Error::other("host unreachable")),
5 => return Err(io::Error::other("connection refused")),
6 => return Err(io::Error::other("TTL expired")),
7 => return Err(io::Error::other("command not supported")),
8 => return Err(io::Error::other("address kind not supported")),
_ => return Err(io::Error::other("unknown error")),
}

if socket.read_u8()? != 0 {
Expand Down Expand Up @@ -227,14 +204,11 @@ impl Socks5Stream {
}

if selected_method == 0xff {
return Err(io::Error::new(
io::ErrorKind::Other,
"no acceptable auth methods",
));
return Err(io::Error::other("no acceptable auth methods"));
}

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

match *auth {
Expand Down
1 change: 1 addition & 0 deletions test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
verify test
1 change: 1 addition & 0 deletions verify.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test