From 800ca15eb9cd015f1a4c53c99ed2b871770d766f Mon Sep 17 00:00:00 2001 From: EAimTY Date: Sat, 20 May 2023 21:17:39 +0900 Subject: [PATCH] close streams immediately after connect error --- tuic-client/Cargo.toml | 6 +++--- tuic-client/src/socks5.rs | 3 ++- tuic-server/Cargo.toml | 6 +++--- tuic-server/src/server.rs | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/tuic-client/Cargo.toml b/tuic-client/Cargo.toml index a47cddc..23c0c4a 100644 --- a/tuic-client/Cargo.toml +++ b/tuic-client/Cargo.toml @@ -12,14 +12,14 @@ lexopt = { version = "0.3.0", default-features = false } log = { version = "0.4.17", default-features = false, features = ["serde", "std"] } once_cell = { version = "1.17.1", default-features = false, features = ["parking_lot", "std"] } parking_lot = { version = "0.12.1", default-features = false, features = ["send_guard"] } -quinn = { version = "0.10.0", default-features = false, features = ["futures-io", "runtime-tokio", "tls-rustls"] } +quinn = { version = "0.10.1", default-features = false, features = ["futures-io", "runtime-tokio", "tls-rustls"] } register-count = { version = "0.1.0", default-features = false, features = ["std"] } rustls = { version = "0.21.1", default-features = false, features = ["quic"] } rustls-native-certs = { version = "0.6.2", default-features = false } rustls-pemfile = { version = "1.0.2", default-features = false } serde = { version = "1.0.163", default-features = false, features = ["derive", "std"] } serde_json = { version = "1.0.96", default-features = false, features = ["std"] } -socket2 = { version = "0.5.2", default-features = false } +socket2 = { version = "0.5.3", default-features = false } socks5-proto = { version = "0.3.3", default-features = false } socks5-server = { version = "0.8.3", default-features = false } thiserror = { version = "1.0.40", default-features = false } @@ -27,4 +27,4 @@ tokio = { version = "1.28.1", default-features = false, features = ["io-util", " tokio-util = { version = "0.7.8", default-features = false, features = ["compat"] } tuic = { path = "../tuic", default-features = false } tuic-quinn = { path = "../tuic-quinn", default-features = false } -uuid = { version = "1.3.2", default-features = false, features = ["serde", "std"] } +uuid = { version = "1.3.3", default-features = false, features = ["serde", "std"] } diff --git a/tuic-client/src/socks5.rs b/tuic-client/src/socks5.rs index a2c9a02..2eef0ea 100644 --- a/tuic-client/src/socks5.rs +++ b/tuic-client/src/socks5.rs @@ -2,6 +2,7 @@ use crate::{config::Local, connection::Connection as TuicConnection, Error}; use bytes::Bytes; use once_cell::sync::OnceCell; use parking_lot::Mutex; +use quinn::VarInt; use socket2::{Domain, Protocol, SockAddr, Socket, Type}; use socks5_proto::{Address, Reply}; use socks5_server::{ @@ -185,7 +186,7 @@ impl Server { Ok(_) => Ok(()), Err(err) => { let _ = conn.shutdown().await; - let _ = relay.shutdown().await; + let _ = relay.get_mut().reset(VarInt::from_u32(0)); Err(Error::from(err)) } }, diff --git a/tuic-server/Cargo.toml b/tuic-server/Cargo.toml index 4773dfb..7147ee3 100644 --- a/tuic-server/Cargo.toml +++ b/tuic-server/Cargo.toml @@ -11,16 +11,16 @@ humantime = { version = "2.1.0", default-features = false } lexopt = { version = "0.3.0", default-features = false } log = { version = "0.4.17", default-features = false, features = ["serde", "std"] } parking_lot = { version = "0.12.1", default-features = false } -quinn = { version = "0.10.0", default-features = false, features = ["futures-io", "runtime-tokio", "tls-rustls"] } +quinn = { version = "0.10.1", default-features = false, features = ["futures-io", "runtime-tokio", "tls-rustls"] } register-count = { version = "0.1.0", default-features = false, features = ["std"] } rustls = { version = "0.21.1", default-features = false, features = ["quic"] } rustls-pemfile = { version = "1.0.2", default-features = false } serde = { version = "1.0.163", default-features = false, features = ["derive", "std"] } serde_json = { version = "1.0.96", default-features = false, features = ["std"] } -socket2 = { version = "0.5.2", default-features = false } +socket2 = { version = "0.5.3", default-features = false } thiserror = { version = "1.0.40", default-features = false } tokio = { version = "1.28.1", default-features = false, features = ["io-util", "macros", "net", "parking_lot", "rt-multi-thread", "time"] } tokio-util = { version = "0.7.8", default-features = false, features = ["compat"] } tuic = { path = "../tuic", default-features = false } tuic-quinn = { path = "../tuic-quinn", default-features = false } -uuid = { version = "1.3.2", default-features = false, features = ["serde", "std"] } +uuid = { version = "1.3.3", default-features = false, features = ["serde", "std"] } diff --git a/tuic-server/src/server.rs b/tuic-server/src/server.rs index ea68d51..64216ab 100644 --- a/tuic-server/src/server.rs +++ b/tuic-server/src/server.rs @@ -471,7 +471,7 @@ impl Connection { if let Some(mut stream) = stream { let mut conn = conn.compat(); let res = io::copy_bidirectional(&mut conn, &mut stream).await; - let _ = conn.shutdown().await; + let _ = conn.get_mut().reset(VarInt::from_u32(0)); let _ = stream.shutdown().await; res?; Ok(())