aboutsummaryrefslogtreecommitdiff
path: root/serve_mx.go
diff options
context:
space:
mode:
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":