Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion internal/server/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@ func buildCapabilities(deps ServerDeps, isTLS bool) []string {
return capabilities
}

func HandleCapability(deps ServerDeps, conn net.Conn, tag string, state *models.ClientState) {
func HandleCapability(deps ServerDeps, conn net.Conn, tag string, parts []string, state *models.ClientState) {
// RFC 3501: CAPABILITY takes no arguments.
if len(parts) > 2 {
deps.SendResponse(conn, fmt.Sprintf("%s BAD CAPABILITY takes no arguments", tag))
return
}
// Detect TLS: real TLS connection or test mock that advertises TLS
isTLS := false
if _, ok := conn.(*tls.Conn); ok {
Expand Down
2 changes: 1 addition & 1 deletion internal/server/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func handleClient(s *IMAPServer, conn net.Conn, state *models.ClientState) {

switch cmd {
case "CAPABILITY":
auth.HandleCapability(s, conn, tag, state)
auth.HandleCapability(s, conn, tag, parts, state)
case "LOGIN":
auth.HandleLogin(s, conn, tag, parts, state)
case "AUTHENTICATE":
Expand Down
2 changes: 1 addition & 1 deletion internal/server/testing_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func NewTestInterface(server *IMAPServer) *TestInterface {

// HandleCapability exposes the capability handler for testing
func (t *TestInterface) HandleCapability(conn net.Conn, tag string, state *models.ClientState) {
auth.HandleCapability(t.server, conn, tag, state)
auth.HandleCapability(t.server, conn, tag, []string{tag, "CAPABILITY"}, state)
}

// HandleLogin exposes the login handler for testing
Expand Down
Loading