Skip to content

Commit 41768ea

Browse files
committed
chore: apply clippy lints
1 parent fe5912f commit 41768ea

5 files changed

Lines changed: 12 additions & 18 deletions

File tree

cspell.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"userWords": [
3+
"reqwest"
4+
]
5+
}

src/servers/http.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use hyper::{
1212
use log::error;
1313
use std::{
1414
convert::Infallible,
15-
io::ErrorKind,
1615
net::{Ipv4Addr, SocketAddr, SocketAddrV4},
1716
sync::Arc,
1817
};
@@ -37,9 +36,7 @@ pub async fn start_http_server(ctx: Arc<ClientContext>) -> std::io::Result<()> {
3736

3837
let server = Server::bind(&addr).serve(make_svc);
3938

40-
server
41-
.await
42-
.map_err(|err| std::io::Error::new(ErrorKind::Other, err))
39+
server.await.map_err(std::io::Error::other)
4340
}
4441

4542
/// Handles an HTTP request from the HTTP acting as a proxy

src/servers/telemetry.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ fn xor_cipher(input: &[u8], key: &[u8]) -> Vec<u8> {
127127
// Iterate along-side the key
128128
.zip(key.iter().cycle().copied())
129129
// Process the next value using the key
130-
.map(|(data, key)| ((data ^ key) % 0x80))
130+
.map(|(data, key)| (data ^ key) % 0x80)
131131
// Collect the processed bytes
132132
.collect()
133133
}

src/servers/tunnel.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ use log::{debug, error};
1818
use reqwest::Upgraded;
1919
use std::{
2020
future::Future,
21-
io::ErrorKind,
2221
net::{Ipv4Addr, SocketAddr, SocketAddrV4},
2322
pin::Pin,
2423
sync::Arc,
@@ -85,10 +84,7 @@ pub async fn start_tunnel_server(ctx: Arc<ClientContext>) -> std::io::Result<()>
8584
tokio::time::sleep(reconnect_time).await;
8685
}
8786

88-
Err(last_error.unwrap_or(std::io::Error::new(
89-
ErrorKind::Other,
90-
"Reached error connect limit",
91-
)))
87+
Err(last_error.unwrap_or(std::io::Error::other("Reached error connect limit")))
9288
}
9389

9490
/// Creates a new tunnel
@@ -103,7 +99,7 @@ async fn create_tunnel(ctx: Arc<ClientContext>, association: &str) -> std::io::R
10399
// Wrap the tunnel with the [`TunnelCodec`] framing
104100
.map(|io| Framed::new(io, TunnelCodec::default()))
105101
// Wrap the error into an [`std::io::Error`]
106-
.map_err(|err| std::io::Error::new(ErrorKind::Other, err))?;
102+
.map_err(std::io::Error::other)?;
107103
debug!("Created server tunnel");
108104

109105
// Allocate the socket pool for the tunnel
@@ -496,7 +492,7 @@ mod codec {
496492
//! Tunnel message frames are as follows:
497493
//!
498494
//! ```text
499-
//! 0 1 2
495+
//! 0 1 2
500496
//! 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3
501497
//! +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
502498
//! | Index | Length |

src/servers/udp_tunnel.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use pocket_relay_udp_tunnel::{
1414
};
1515
use std::{
1616
future::Future,
17-
io::ErrorKind,
1817
net::{Ipv4Addr, SocketAddr, SocketAddrV4},
1918
pin::Pin,
2019
sync::Arc,
@@ -142,11 +141,8 @@ pub async fn start_udp_tunnel_server(
142141
}
143142

144143
Err(last_error
145-
.map(|err| std::io::Error::new(ErrorKind::Other, err))
146-
.unwrap_or(std::io::Error::new(
147-
ErrorKind::Other,
148-
"Reached error connect limit",
149-
)))
144+
.map(std::io::Error::other)
145+
.unwrap_or(std::io::Error::other("Reached error connect limit")))
150146
}
151147

152148
/// Creates a new tunnel

0 commit comments

Comments
 (0)