From: Morya Date: Wed, 28 Jul 2021 21:09:35 +0000 (+0800) Subject: Fix: reply 235 when client auth success, according to rfc2554 (#1) X-Git-Tag: v2.1.0~5 X-Git-Url: https://src.bluestatic.org/?a=commitdiff_plain;h=871860fc496ba30522f11fc8d241a3ce50e68f16;p=mailpopbox.git Fix: reply 235 when client auth success, according to rfc2554 (#1) --- diff --git a/smtp/conn.go b/smtp/conn.go index 30a6359..939c900 100644 --- a/smtp/conn.go +++ b/smtp/conn.go @@ -312,7 +312,7 @@ func (conn *connection) doAUTH() { conn.log.Info("authenticated", zap.String("authz", authParts[0]), zap.String("authc", authParts[1])) conn.authc = authParts[1] - conn.reply(ReplyOK) + conn.reply(ReplyAuthOK) } func (conn *connection) doMAIL() { diff --git a/smtp/conn_test.go b/smtp/conn_test.go index 0dc8263..6ae0be7 100644 --- a/smtp/conn_test.go +++ b/smtp/conn_test.go @@ -411,7 +411,7 @@ func TestAuth(t *testing.T) { {"AUTH PLAIN ", 334, nil}, {"this isn't base 64", 501, nil}, {"AUTH PLAIN ", 334, nil}, - {b64enc("-authz-\x00-authc-\x00goats"), 250, nil}, + {b64enc("-authz-\x00-authc-\x00goats"), 235, nil}, {"AUTH PLAIN ", 503, nil}, // Already authenticated. {"NOOP", 250, nil}, }) @@ -431,7 +431,7 @@ func TestAuthNoInitialResponse(t *testing.T) { conn := setupTLSClient(t, l.Addr()) runTableTest(t, conn, []requestResponse{ - {"AUTH PLAIN " + b64enc("\x00user\x00longpassword"), 250, nil}, + {"AUTH PLAIN " + b64enc("\x00user\x00longpassword"), 235, nil}, }) } @@ -453,7 +453,7 @@ func TestRelayRequiresAuth(t *testing.T) { {"MAIL FROM:", 550, nil}, {"MAIL FROM:", 550, nil}, {"AUTH PLAIN ", 334, nil}, - {b64enc("\x00mailbox@example.com\x00test"), 250, nil}, + {b64enc("\x00mailbox@example.com\x00test"), 235, nil}, {"MAIL FROM:", 250, nil}, }) } @@ -472,7 +472,7 @@ func setupRelayTest(t *testing.T) (server *testServer, l net.Listener, conn *tex conn = setupTLSClient(t, l.Addr()) runTableTest(t, conn, []requestResponse{ {"AUTH PLAIN ", 334, nil}, - {b64enc("\x00mailbox@example.com\x00test"), 250, nil}, + {b64enc("\x00mailbox@example.com\x00test"), 235, nil}, }) return } diff --git a/smtp/server.go b/smtp/server.go index 8697eb1..0f72e32 100644 --- a/smtp/server.go +++ b/smtp/server.go @@ -31,6 +31,7 @@ var SendAsSubject = regexp.MustCompile(`(?i)\[sendas:\s*([a-zA-Z0-9\.\-_]+)\]`) var ( ReplyOK = ReplyLine{250, "OK"} + ReplyAuthOK = ReplyLine{235, "auth success"} ReplyBadSyntax = ReplyLine{501, "syntax error"} ReplyBadSequence = ReplyLine{503, "bad sequence of commands"} ReplyBadMailbox = ReplyLine{550, "mailbox unavailable"}