From 119ec04d0ce7e55b54b8f0a8d17282de30fe8431 Mon Sep 17 00:00:00 2001 From: _ <> Date: Mon, 25 Oct 2021 00:58:53 +0000 Subject: [PATCH] trying to protect against spam a little --- telnet/src/main.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/telnet/src/main.rs b/telnet/src/main.rs index ab94b4f..2b6838d 100644 --- a/telnet/src/main.rs +++ b/telnet/src/main.rs @@ -49,6 +49,10 @@ async fn read_input ( } } + if ! buffer.contains (&b'\n') { + anyhow::bail! ("No newline. User might be spamming us or something."); + } + let buffer = String::from_utf8 (buffer)?; // I don't know why I need the type annotation here, but I do. @@ -101,13 +105,16 @@ async fn process_socket (socket: TcpStream, id: &str) } }, Response::Sleep (x) => sleep (x).await, - Response::PlayerVictory => tracing::info! ("Connection {} beat the game", id), + Response::PlayerVictory => tracing::info! ("Connection {} PlayerVictory", id), + Response::JokeEnding => tracing::info! ("Connection {} JokeEnding", id), Response::Quit => break 'main_loop, _ => (), } } } + tracing::info! ("Connection {} ending gracefully", id); + Ok (()) }