Skip to content

Commit

Permalink
allow handlers to handle unrecognized messages
Browse files Browse the repository at this point in the history
  • Loading branch information
merlinz01 committed Apr 13, 2024
1 parent 6000c6d commit 9a224a7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ type Handler interface {
ModifyDN(*Conn, *Message, *ModifyDNRequest)
// Perform a Search request
Search(*Conn, *Message, *SearchRequest)
// Handle unrecognized requests
Other(*Conn, *Message)
}

// Basic server functionality.
Expand Down Expand Up @@ -104,3 +106,7 @@ func (*BaseHandler) StartTLS(conn *Conn, msg *Message) {
}
conn.SendResult(msg.MessageID, nil, TypeExtendedResponseOp, &res)
}

func (*BaseHandler) Other(conn *Conn, msg *Message) {
conn.SendResult(msg.MessageID, nil, BerTypeSequence, UnsupportedOperation)
}
2 changes: 1 addition & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,6 @@ func (s *LDAPServer) handleMessage(conn *Conn, msg *Message) {
conn.Close()
default:
log.Println("Unknown operation type:", msg.ProtocolOp.Type)
conn.SendResult(msg.MessageID, nil, BerTypeSequence, UnsupportedOperation)
s.Handler.Other(conn, msg)
}
}

0 comments on commit 9a224a7

Please sign in to comment.