From 20e67f650b1e3a5dca584f5a468ce0e558075f49 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Tue, 31 Dec 2024 16:40:54 +0000 Subject: Implement QUIT and RSET --- main.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/main.go b/main.go index cdd6b11..d894d8c 100644 --- a/main.go +++ b/main.go @@ -173,6 +173,16 @@ func handle_connection(reader *bufio.Reader, writer *bufio.Writer) error { server_state = server_state_helo _, _ = writer.WriteString("250 2.0.0 Ok: Accepted\r\n") _ = writer.Flush() + case "QUIT": + _, _ = writer.WriteString("221 2.0.0 Bye\r\n") + _ = writer.Flush() + return nil + case "RSET": + if server_state != server_state_begin { + server_state = server_state_helo + } + _, _ = writer.WriteString("250 2.0.0 Ok\r\n") + _ = writer.Flush() default: _, _ = writer.WriteString("500 5.5.2 Error: command not recognized\r\n") _ = writer.Flush() -- cgit v1.2.3