Skip to content

Commit d72e978

Browse files
committed
feat: optimize log
1 parent 7645f28 commit d72e978

File tree

5 files changed

+10
-16
lines changed

5 files changed

+10
-16
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "shuttle"
3-
version = "0.6.8"
3+
version = "0.6.9"
44
edition = "2021"
55
publish = false
66

src/rathole/cmd/dial.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,7 @@ impl DialConn {
6868
let conn_sender = ConnSender::new(conn_id, tx);
6969
context.with_conn_id(conn_id);
7070
context.set_conn_sender(conn_sender).await;
71-
if let Err(e) = exchange_copy(stream, rx, context.clone()).await {
72-
debug!("exchange copy close: {}", e);
73-
}
71+
exchange_copy(stream, rx, context.clone()).await;
7472
context.remove_conn_sender().await;
7573
});
7674
Ok(())

src/rathole/cmd/hole.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl HoleServer {
101101
let (tx, rx) = mpsc::channel(1);
102102

103103
let conn_id = self.id_adder.add_and_get().await;
104-
info!("Hole accept proxy conn {conn_id}");
104+
info!("Hole accept proxy conn ({conn_id})");
105105
let conn_sender = ConnSender::new(conn_id, tx);
106106
self.context.set_conn_sender(conn_sender).await;
107107

@@ -111,9 +111,7 @@ impl HoleServer {
111111
let dial = Command::Dial(Dial::new(conn_id, self.local_addr.clone()));
112112
context.command_sender.send_sync(dial).await?;
113113
tokio::spawn(async move {
114-
if let Err(e) = exchange_copy(ts, rx, context.clone()).await {
115-
debug!("exchange copy close : {}", e);
116-
}
114+
exchange_copy(ts, rx, context.clone()).await;
117115
context.remove_conn_sender().await;
118116
});
119117
}

src/rathole/mod.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,7 @@ async fn handle<T: AsyncRead + AsyncWrite + Unpin + Send + 'static>(
102102
rx.await.context("Dispatcher stop")?
103103
}
104104

105-
async fn exchange_copy(
106-
ts: TcpStream,
107-
mut rx: mpsc::Receiver<Bytes>,
108-
context: context::Context,
109-
) -> anyhow::Result<()> {
105+
async fn exchange_copy(ts: TcpStream, mut rx: mpsc::Receiver<Bytes>, context: context::Context) {
110106
let (mut r, mut w) = io::split(ts);
111107
let mut shutdown = context.notify_shutdown.subscribe();
112108
info!(
@@ -120,12 +116,14 @@ async fn exchange_copy(
120116
debug!("exchange recv shutdown signal");
121117
Ok(())
122118
}
123-
}?;
119+
}
120+
.inspect_err(|e| debug!("exchange copy faield {e}"))
121+
.ok();
122+
124123
info!(
125124
"stop stream copy by exchange conn_id: {:?}",
126125
context.current_conn_id
127126
);
128-
Ok(())
129127
}
130128

131129
async fn read_bytes(r: &mut ReadHalf<TcpStream>, context: context::Context) -> anyhow::Result<()> {

0 commit comments

Comments
 (0)