aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--serve_mx.go37
1 files changed, 20 insertions, 17 deletions
diff --git a/serve_mx.go b/serve_mx.go
index 8911486..b8e6d44 100644
--- a/serve_mx.go
+++ b/serve_mx.go
@@ -49,25 +49,28 @@ func (session *mx_recv_session) handle(ctx context.Context) error {
_ = session.buf_conn.Flush()
session.server_state = mx_server_state_begin
for {
- line, err := session.buf_conn.ReadString('\n')
- if err != nil {
- if err == io.EOF {
- return err_connection_handler_eof
+ 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
}
- 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 = 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
+ }
+ cmd = strings.ToUpper(line[:cmd_end])
+ param = line[param_start:]
}
- cmd := strings.ToUpper(line[:cmd_end])
- param := line[param_start:]
switch_cmd:
switch cmd {
case "STARTTLS":