From c38f64b815b429ca04993d5504b8e266e28d095a Mon Sep 17 00:00:00 2001 From: ssrlive <30760636+ssrlive@users.noreply.github.com> Date: Sat, 14 Dec 2024 21:32:42 +0800 Subject: [PATCH] upgrade dependencies --- Cargo.toml | 14 ++++++++------ src/client.rs | 6 +++--- src/server.rs | 7 +++---- src/udprelay.rs | 6 +++--- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3a3d9cd..e6a75fe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,10 +11,6 @@ rust-version = "1.80" [lib] crate-type = ["staticlib", "cdylib", "lib"] -[[bin]] -name = "overtls-bin" -path = "src/bin/main.rs" - [dependencies] async-shared-timeout = "0.2" base64 = "0.22" @@ -47,7 +43,9 @@ rustls-pemfile = "2" serde = { version = "1", features = ["derive"] } serde_json = "1" socket2 = "0.5" -socks5-impl = "0.5" +socks5-impl = { version = "0.6", default-features = false, features = [ + "server", +] } thiserror = "2" tokio = { version = "1", features = ["full"] } tokio-rustls = { version = "0.26", default-features = false, features = [ @@ -55,7 +53,7 @@ tokio-rustls = { version = "0.26", default-features = false, features = [ "tls12", "ring", ] } -tokio-tungstenite = { version = "0.24", features = ["rustls-tls-webpki-roots"] } +tokio-tungstenite = { version = "0.25", features = ["rustls-tls-webpki-roots"] } tokio-util = "0.7" url = "2" webpki = { package = "rustls-webpki", version = "0.102", features = [ @@ -64,6 +62,10 @@ webpki = { package = "rustls-webpki", version = "0.102", features = [ ] } webpki-roots = "0.26" +[[bin]] +name = "overtls-bin" +path = "src/bin/main.rs" + [target.'cfg(unix)'.dependencies] daemonize = "0.5" diff --git a/src/client.rs b/src/client.rs index efab029..39f66bf 100644 --- a/src/client.rs +++ b/src/client.rs @@ -180,7 +180,7 @@ async fn client_traffic_loop {} length {}", peer_addr, target_addr, buf.len()); if let Err(e) = crate::traffic_status::traffic_status_update(len, 0) { @@ -198,7 +198,7 @@ async fn client_traffic_loop { - incoming.write_all(&data).await?; + incoming.write_all(data.as_slice()).await?; log::trace!("{} <- {} length {}", peer_addr, target_addr, data.len()); } Message::Close(_) => { @@ -212,7 +212,7 @@ async fn client_traffic_loop { - ws_stream.send(Message::Ping(vec![])).await?; + ws_stream.send(Message::Ping(vec![].into())).await?; log::trace!("{} -> {} Websocket ping from local", peer_addr, target_addr); } } diff --git a/src/server.rs b/src/server.rs index 43ac8d5..f19b572 100644 --- a/src/server.rs +++ b/src/server.rs @@ -351,7 +351,7 @@ async fn normal_tunnel( break; } Message::Text(_) | Message::Binary(_) => { - outgoing.write_all(&msg.into_data()).await?; + outgoing.write_all(msg.into_data().as_slice()).await?; } _ => {} } @@ -364,7 +364,7 @@ async fn normal_tunnel( break; } Ok(n) => { - let msg = Message::Binary(buffer[..n].to_vec()); + let msg = Message::binary(buffer[..n].to_vec()); let len = (msg.len() + WS_MSG_HEADER_LEN) as u64; log::trace!("{peer} <- {dst_addr} length {}", len); if let Some(client_id) = &client_id { @@ -410,8 +410,7 @@ async fn create_udp_tunnel( break; } if msg.is_text() || msg.is_binary() { - let data = msg.into_data(); - let mut buf = BytesMut::from(&data[..]); + let mut buf = BytesMut::from(&msg.into_data().as_mut_slice()[..]); let dst_addr = Address::try_from(&buf[..])?; let _ = buf.split_to(dst_addr.len()); let src_addr = Address::try_from(&buf[..])?; diff --git a/src/udprelay.rs b/src/udprelay.rs index 4bb80ca..ce04b76 100644 --- a/src/udprelay.rs +++ b/src/udprelay.rs @@ -197,7 +197,7 @@ async fn _run_udp_loop( } else { log::debug!("[UDP] {src_addr} -> {dst_addr} send to remote size {}", buf.len()); } - let msg = Message::Binary(buf.freeze().to_vec()); + let msg = Message::binary(buf.freeze().to_vec()); ws_stream.send(msg).await?; } else { // log::trace!("[UDP] {dst_addr} <- {src_addr} skip feedback packet"); @@ -212,7 +212,7 @@ async fn _run_udp_loop( match msg { Some(Ok(Message::Binary(buf))) => { - let mut buf = BytesMut::from(&buf[..]); + let mut buf = BytesMut::from(buf.as_slice()); let incoming_addr = Address::try_from(&buf[..])?; let _ = buf.split_to(incoming_addr.len()); let remote_addr = Address::try_from(&buf[..])?; @@ -256,7 +256,7 @@ async fn _run_udp_loop( Ok::<_, Error>(()) }, _ = timer.tick() => { - ws_stream.send(Message::Ping(vec![])).await?; + ws_stream.send(Message::Ping(vec![].into())).await?; log::trace!("[UDP] Websocket ping from local"); Ok::<_, Error>(()) }