mirror of
https://gitlab.com/ric_harvey/MailHog.git
synced 2025-02-20 01:35:56 +00:00
Multiple messages per connection, advertise pipelining
This commit is contained in:
parent
6fdecf81e3
commit
6282d54682
1 changed files with 4 additions and 17 deletions
|
@ -78,7 +78,7 @@ func (c *Session) Parse() {
|
||||||
if(strings.HasSuffix(c.message.Data, "\r\n.\r\n")) {
|
if(strings.HasSuffix(c.message.Data, "\r\n.\r\n")) {
|
||||||
c.message.Data = strings.TrimSuffix(c.message.Data, "\r\n.\r\n")
|
c.message.Data = strings.TrimSuffix(c.message.Data, "\r\n.\r\n")
|
||||||
id, err := c.mongo.Store(c.message)
|
id, err := c.mongo.Store(c.message)
|
||||||
c.state = DONE
|
c.state = MAIL
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// FIXME
|
// FIXME
|
||||||
c.Write("500", "Error")
|
c.Write("500", "Error")
|
||||||
|
@ -99,10 +99,10 @@ func (c *Session) Write(code string, text ...string) {
|
||||||
c.conn.Write([]byte(code + " " + text[0] + "\n"))
|
c.conn.Write([]byte(code + " " + text[0] + "\n"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for i := 0; i < len(text) - 2; i++ {
|
for i := 0; i < len(text) - 1; i++ {
|
||||||
c.conn.Write([]byte(code + "-" + text[i] + "\n"))
|
c.conn.Write([]byte(code + "-" + text[i] + "\n"))
|
||||||
}
|
}
|
||||||
c.conn.Write([]byte(code + " " + text[len(text)] + "\n"))
|
c.conn.Write([]byte(code + " " + text[len(text)-1] + "\n"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Session) Process(line string) {
|
func (c *Session) Process(line string) {
|
||||||
|
@ -140,7 +140,7 @@ func (c *Session) Process(line string) {
|
||||||
c.log("Got EHLO command, switching to MAIL state")
|
c.log("Got EHLO command, switching to MAIL state")
|
||||||
c.state = MAIL
|
c.state = MAIL
|
||||||
c.message.Helo = args
|
c.message.Helo = args
|
||||||
c.Write("250", "Hello " + args)
|
c.Write("250", "Hello " + args, "PIPELINING")
|
||||||
default:
|
default:
|
||||||
c.log("Got unknown command for ESTABLISH state: '%s'", command)
|
c.log("Got unknown command for ESTABLISH state: '%s'", command)
|
||||||
}
|
}
|
||||||
|
@ -172,18 +172,5 @@ func (c *Session) Process(line string) {
|
||||||
default:
|
default:
|
||||||
c.log("Got unknown command for RCPT state: '%s'", command)
|
c.log("Got unknown command for RCPT state: '%s'", command)
|
||||||
}
|
}
|
||||||
case c.state == DONE:
|
|
||||||
switch command {
|
|
||||||
/*
|
|
||||||
case "MAIL":
|
|
||||||
c.log("Got MAIL command")
|
|
||||||
// TODO parse args
|
|
||||||
c.message.From = args
|
|
||||||
c.state = RCPT
|
|
||||||
c.Write("250", "Ok")
|
|
||||||
*/
|
|
||||||
default:
|
|
||||||
c.log("Got unknown command for DONE state: '%s'", command)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue