From d68caf8e3c4910f80c707c0673160087cbca0146 Mon Sep 17 00:00:00 2001 From: Noratrieb <48135649+Noratrieb@users.noreply.github.com> Date: Thu, 15 Aug 2024 15:26:50 +0200 Subject: [PATCH] cleanup --- src/main.rs | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/src/main.rs b/src/main.rs index fa26f08..32a92cc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -141,21 +141,6 @@ async fn handle_connection( } } ChannelRequest::Shell { want_reply } => { - state.do_operation( - update.number.construct_op(ChannelOperationKind::Data( - vec![b'a'; 1_000_000], - )), - ); - state.do_operation( - update.number.construct_op(ChannelOperationKind::Data( - vec![b'b'; 1_000_000], - )), - ); - state.do_operation( - update.number.construct_op(ChannelOperationKind::Data( - vec![b'c'; 1_000_000], - )), - ); if want_reply { state.do_operation(success); } @@ -191,11 +176,14 @@ async fn handle_connection( }; } ChannelUpdateKind::Data { data } => { - let is_eof = data.contains(&0x03 /*EOF, Ctrl-C*/); + let is_eof = data.contains(&0x04 /*EOF, Ctrl-D*/); // echo :3 - // state - // .do_operation(update.number.construct_op(ChannelOperationKind::Data(data))); + state.do_operation( + update + .number + .construct_op(ChannelOperationKind::Data(data.clone())), + ); // arbitrary limit if total_sent_data.len() < 50_000 { @@ -204,15 +192,16 @@ async fn handle_connection( info!(channel = %update.number, "Reached stdin limit"); state.do_operation( update.number.construct_op(ChannelOperationKind::Data( - b"Thanks Hayley!".to_vec(), + b"Thanks Hayley!\n".to_vec(), )), ); - //state.do_operation(update.number.construct_op(ChannelOperationKind::Close)); + state.do_operation(update.number.construct_op(ChannelOperationKind::Close)); } - if false && is_eof { - debug!(channel = %update.number, "Received Ctrl-C, closing channel"); + if is_eof { + debug!(channel = %update.number, "Received Ctrl-D, closing channel"); + state.do_operation(update.number.construct_op(ChannelOperationKind::Eof)); state.do_operation(update.number.construct_op(ChannelOperationKind::Close)); } }