From acd19b1f2d8d5fa1a86e742be38fc5c33f1ef9d6 Mon Sep 17 00:00:00 2001 From: Dwayne Page Date: Sat, 2 Nov 2024 14:02:50 -0500 Subject: [PATCH] implement help --- conn.go | 4 +++- server_test.go | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/conn.go b/conn.go index acba983..0388e6d 100644 --- a/conn.go +++ b/conn.go @@ -107,7 +107,7 @@ func (c *Conn) handle(cmd string, arg string) { cmd = strings.ToUpper(cmd) switch cmd { - case "SEND", "SOML", "SAML", "EXPN", "HELP", "TURN": + case "SEND", "SOML", "SAML", "EXPN", "TURN": // These commands are not implemented in any state c.writeResponse(502, EnhancedCode{5, 5, 1}, fmt.Sprintf("%v command not implemented", cmd)) case "HELO", "EHLO", "LHLO": @@ -144,6 +144,8 @@ func (c *Conn) handle(cmd string, arg string) { c.handleAuth(arg) case "STARTTLS": c.handleStartTLS() + case "HELP": + c.writeResponse(214, EnhancedCode{2, 0, 0}, "By helping others, you help yourself") default: msg := fmt.Sprintf("Syntax errors, %v command unrecognized", cmd) c.protocolError(500, EnhancedCode{5, 5, 2}, msg) diff --git a/server_test.go b/server_test.go index 206d336..d0fc902 100644 --- a/server_test.go +++ b/server_test.go @@ -726,7 +726,7 @@ func TestServer_otherCommands(t *testing.T) { io.WriteString(c, "HELP\r\n") scanner.Scan() - if !strings.HasPrefix(scanner.Text(), "502 ") { + if !strings.HasPrefix(scanner.Text(), "214 ") { t.Fatal("Invalid HELP response:", scanner.Text()) }