-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtransaction_handler.go
56 lines (50 loc) · 1.28 KB
/
transaction_handler.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package msmtpd
import "fmt"
func (t *Transaction) handle(line string) {
t.LogDebug("Command received: %s", line)
cmd := parseLine(line)
// Commands are dispatched to the appropriate handler functions.
// If a network error occurs during handling, the handler should
// just return and let the error be handled on the next read.
switch cmd.action {
case "PROXY":
t.handlePROXY(cmd)
case "HELO":
t.handleHELO(cmd)
case "EHLO":
t.handleEHLO(cmd)
case "MAIL":
t.handleMAIL(cmd)
case "RCPT":
t.handleRCPT(cmd)
case "STARTTLS":
t.handleSTARTTLS(cmd)
case "DATA":
t.handleDATA(cmd)
case "RSET":
t.handleRSET(cmd)
case "NOOP":
t.handleNOOP(cmd)
case "QUIT":
t.handleQUIT(cmd)
case "AUTH":
t.handleAUTH(cmd)
case "XCLIENT":
t.handleXCLIENT(cmd)
default:
t.Hate(unknownCommandPenalty)
t.LogDebug("Unsupported command received: %s", line)
t.reply(502, "Unsupported command.")
}
}
func (t *Transaction) handleRSET(_ command) {
t.reset()
t.reply(250, "I forgot everything you have said, go ahead please!")
}
func (t *Transaction) handleNOOP(_ command) {
t.reply(250, "I'm finishing procrastinating, go ahead please!")
}
func (t *Transaction) handleQUIT(_ command) {
t.reply(221, fmt.Sprintf("Farewell, my friend! Transaction %s is finished", t.ID))
t.close()
}