Skip to content

Commit

Permalink
refactor: remove futures-io
Browse files Browse the repository at this point in the history
  • Loading branch information
Itsusinn committed Dec 21, 2024
1 parent 6196418 commit 6cb2257
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 8 deletions.
2 changes: 2 additions & 0 deletions tuic-client/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![feature(let_chains)]

use std::{env, process};

use env_logger::Builder as LoggerBuilder;
Expand Down
1 change: 0 additions & 1 deletion tuic-client/src/socks5/handle_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use socks5_server::{
connection::{associate, bind, connect},
};
use tokio::io::{self, AsyncWriteExt};
use tokio_util::compat::FuturesAsyncReadCompatExt;
use tuic::Address as TuicAddress;

use super::{Server, UDP_SESSIONS, udp_session::UdpSession};
Expand Down
3 changes: 2 additions & 1 deletion tuic-quinn/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ repository.workspace = true
[dependencies]
tracing = { version = "0.1", default-features = false}
bytes = { version = "1", default-features = false, features = ["std"] }
futures-util = { version = "0.3", default-features = false, features = ["io", "std"] }
quinn = { version = "0.11", default-features = false, features = ["futures-io"]}
thiserror = { version = "2", default-features = false }
tuic = { path = "../tuic", default-features = false, features = ["async_marshal", "marshal", "model"] }
uuid = { version = "1", default-features = false, features = ["std"] }
tokio = { version = "1", default-features = false, features = ["io-util"] }
eyre = { version = "0" }
2 changes: 1 addition & 1 deletion tuic-quinn/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ use std::{
};

use bytes::{BufMut, Bytes, BytesMut};
use futures_util::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt};
pub use quinn;
use quinn::{
ClosedStream, Connection as QuinnConnection, ConnectionError, RecvStream, SendDatagramError,
SendStream, VarInt,
};
use thiserror::Error;
use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, ReadBuf};
use tracing::warn;
use tuic::{
Address, Header, UnmarshalError,
Expand Down
1 change: 0 additions & 1 deletion tuic-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ register-count = { version = "0.1.0", default-features = false, features = ["std

# Tokio/Async
tokio = { version = "1", default-features = false, features = ["io-util", "macros", "net", "parking_lot", "rt-multi-thread", "time", "fs", "signal"] }
tokio-util = { version = "0.7", default-features = false, features = ["compat"] }

# TLS
rustls = { version = "0.23", default-features = false }
Expand Down
6 changes: 2 additions & 4 deletions tuic-server/src/connection/handle_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use tokio::{
io::{self, AsyncWriteExt},
net::{self, TcpStream},
};
use tokio_util::compat::FuturesAsyncReadCompatExt;
use tracing::{info, warn};
use tuic::Address;
use tuic_quinn::{Authenticate, Connect, Packet};
Expand Down Expand Up @@ -60,9 +59,8 @@ impl Connection {
}

if let Some(mut stream) = stream {
let mut conn = conn.compat();
let res = io::copy_bidirectional(&mut conn, &mut stream).await;
_ = conn.get_mut().reset(ERROR_CODE);
_ = conn.reset(ERROR_CODE);
_ = stream.shutdown().await;
// a -> b tx
// a <- b rx
Expand All @@ -72,7 +70,7 @@ impl Connection {
restful::traffic_rx(&self.ctx, &uuid, rx);
Ok::<_, Error>(())
} else {
let _ = conn.compat().shutdown().await;
let _ = conn.shutdown().await;
Err(last_err
.unwrap_or_else(|| IoError::new(ErrorKind::NotFound, "no address resolved")))?
}
Expand Down

0 comments on commit 6cb2257

Please sign in to comment.