trying to protect against spam a little
							parent
							
								
									36176ef200
								
							
						
					
					
						commit
						119ec04d0c
					
				| 
						 | 
				
			
			@ -49,6 +49,10 @@ async fn read_input <R: AsyncReadExt + Unpin, W: AsyncWrite + Unpin> (
 | 
			
		|||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	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 (())
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue