From 245b60c176685444d4c5378ca2f5fe6326ca5c77 Mon Sep 17 00:00:00 2001 From: Maurice Nonnekes Date: Thu, 15 Feb 2018 09:16:11 +0100 Subject: [PATCH] Don't log EOF error on sudden connection close If a client closes a connection before the `QUIT` command has been issued an EOF error will be reported when logging has been enabled like so: ``` ! command abort 0 bytes read err: EOF ``` Since there appear to be a lot of clients out there who behave like this, catch the io.EOF error and silently close it. The `smtpd.ABORT` event will still be sent when this happens if you want to catch these situations on the implementaton side of things. --- smtpd.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/smtpd.go b/smtpd.go index 31fbba1..8fcdbeb 100644 --- a/smtpd.go +++ b/smtpd.go @@ -522,8 +522,10 @@ func (c *Conn) readCmd() string { if err != nil || c.lr.N == 0 { c.state = sAbort line = "" - c.log("!", "command abort %s err: %v", - fmtBytesLeft(2048, c.lr.N), err) + if err != io.EOF { + c.log("!", "command abort %s err: %v", + fmtBytesLeft(2048, c.lr.N), err) + } } else { c.log("r", line) }