-
-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathhandler_quit.go
29 lines (23 loc) · 912 Bytes
/
handler_quit.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package smtpmock
// QUIT command handler
type handlerQuit struct {
*handler
}
// QUIT command handler builder. Returns pointer to new handlerQuit structure
func newHandlerQuit(session sessionInterface, message *Message, configuration *configuration) *handlerQuit {
return &handlerQuit{&handler{session: session, message: message, configuration: configuration}}
}
// QUIT handler methods
// Main QUIT handler runner
func (handler *handlerQuit) run(request string) {
if handler.isInvalidRequest(request) {
return
}
handler.message.quitSent = true
configuration := handler.configuration
handler.session.writeResponse(configuration.msgQuitCmd, configuration.responseDelayQuit)
}
// Invalid QUIT command predicate. Returns true when request is invalid, otherwise returns false
func (handler *handlerQuit) isInvalidRequest(request string) bool {
return !matchRegex(request, validQuitCmdRegexPattern)
}