trying to fix udp telegram

This commit is contained in:
2026-03-26 19:55:07 +07:00
parent 64d09ee7bf
commit 3eb2df3a34
10 changed files with 65 additions and 59 deletions
+1 -2
View File
@@ -44,7 +44,7 @@ pub(crate) async fn run_tcp_bridge<R, W>(
maybe_data = v_rx.recv() => {
match maybe_data {
Some(data) => {
if data.is_empty() { break; }
if data.is_empty() { continue; }
if let Err(e) = writer.write_all(&data).await {
error!(stream_id, error = %e, "Socket write error");
break;
@@ -103,7 +103,6 @@ pub(crate) async fn run_udp_bridge(
maybe_data = v_rx.recv() => {
match maybe_data {
Some(data) => {
if data.is_empty() { break; }
if let Err(e) = socket.send(&data).await {
error!(stream_id, error = %e, "UDP socket write error");
break;
+8 -15
View File
@@ -193,22 +193,15 @@ impl ClientHandler {
tokio::spawn(async move {
while let Some(payload) = v_rx.recv().await {
if payload.is_empty() {
let close_frame =
RawCastFrame::close(protocol, socket_id, dst_ip, dst_port);
let _ = tx_engine_clone.send(close_frame).await;
let data_frame = RawCastFrame::data(
protocol,
socket_id,
dst_ip,
dst_port,
payload.to_vec(),
);
if tx_engine_clone.send(data_frame).await.is_err() {
break;
} else {
let data_frame = RawCastFrame::data(
protocol,
socket_id,
dst_ip,
dst_port,
payload.to_vec(),
);
if tx_engine_clone.send(data_frame).await.is_err() {
break;
}
}
}
muxer_clone.remove_stream(stream_id);
+4 -3
View File
@@ -41,7 +41,8 @@ impl StreamHandler {
let target_str = String::from_utf8_lossy(&payload).to_string();
let muxer = self.muxer.clone();
let (v_tx, v_rx) = tokio::sync::mpsc::channel(NetworkConfig::global().stream_capacity);
let (v_tx, v_rx) =
tokio::sync::mpsc::channel(NetworkConfig::global().tcp_stream_capacity);
muxer.register_stream(stream_id, v_tx);
tokio::spawn(async move {
@@ -83,7 +84,8 @@ impl StreamHandler {
let target_str = String::from_utf8_lossy(&payload).to_string();
let muxer = self.muxer.clone();
let (v_tx, v_rx) = tokio::sync::mpsc::channel(NetworkConfig::global().stream_capacity);
let (v_tx, v_rx) =
tokio::sync::mpsc::channel(NetworkConfig::global().udp_stream_capacity);
muxer.register_stream(stream_id, v_tx);
tokio::spawn(async move {
@@ -128,7 +130,6 @@ impl StreamHandler {
}
async fn on_close(&self, stream_id: u32) {
self.muxer.dispatch_to_local(stream_id, Bytes::new()).await;
self.muxer.remove_stream(stream_id);
}
}