aboutsummaryrefslogtreecommitdiff
path: root/serve_mx.go
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-01-16 08:56:18 +0800
committerRunxi Yu <me@runxiyu.org>2025-01-16 08:56:18 +0800
commit5079850140ad53d2cdb2395c90cb65061249579c (patch)
tree2e59b51eb2f2c503d5252e77ede6b5eba288ebd8 /serve_mx.go
parentMinor fixes (diff)
downloadmaild-5079850140ad53d2cdb2395c90cb65061249579c.tar.gz
maild-5079850140ad53d2cdb2395c90cb65061249579c.tar.zst
maild-5079850140ad53d2cdb2395c90cb65061249579c.zip
parse_{smtp,imap}_line
Diffstat (limited to 'serve_mx.go')
-rw-r--r--serve_mx.go26
1 files changed, 6 insertions, 20 deletions
diff --git a/serve_mx.go b/serve_mx.go
index b8e6d44..f938c02 100644
--- a/serve_mx.go
+++ b/serve_mx.go
@@ -49,28 +49,14 @@ func (session *mx_recv_session) handle(ctx context.Context) error {
_ = session.buf_conn.Flush()
session.server_state = mx_server_state_begin
for {
- var cmd, param string
- {
- line, err := session.buf_conn.ReadString('\n')
- if err != nil {
- if err == io.EOF {
- return err_connection_handler_eof
- }
- return err
- }
- line = strings.TrimSuffix(line, "\n")
- line = strings.TrimSuffix(line, "\r")
- cmd_end := strings.IndexByte(line, ' ')
- var param_start int
- if cmd_end == -1 {
- cmd_end = len(line)
- param_start = len(line)
- } else {
- param_start = cmd_end + 1
+ line, err := session.buf_conn.ReadString('\n')
+ if err != nil {
+ if err == io.EOF {
+ return err_connection_handler_eof
}
- cmd = strings.ToUpper(line[:cmd_end])
- param = line[param_start:]
+ return err
}
+ cmd, param := parse_smtp_line(line)
switch_cmd:
switch cmd {
case "STARTTLS":