git » chasquid » commit a7afa08

chasquid: Keep an AUTH event log

author Alberto Bertogli
2016-10-12 15:26:04 UTC
committer Alberto Bertogli
2016-10-21 21:13:39 UTC
parent 6747f0785e1537935c9f44afa1e9ba58656ea1a6

chasquid: Keep an AUTH event log

This patch adds an AUTH event log, to help troubleshoot issues with
authentication.

chasquid.go +9 -0

diff --git a/chasquid.go b/chasquid.go
index 13c4c7a..239f9bc 100644
--- a/chasquid.go
+++ b/chasquid.go
@@ -55,6 +55,11 @@ var (
 	tlsCount          = expvar.NewMap("chasquid/smtpIn/tlsCount")
 )
 
+// Global event logs.
+var (
+	authLog = trace.NewEventLog("Authentication", "Incoming SMTP")
+)
+
 func main() {
 	flag.Parse()
 
@@ -1013,9 +1018,13 @@ func (c *Conn) AUTH(params string) (code int, msg string) {
 		c.authUser = user
 		c.authDomain = domain
 		c.completedAuth = true
+		authLog.Debugf("%s successful for %s@%s",
+			c.netconn.RemoteAddr().String(), user, domain)
 		return 235, ""
 	}
 
+	authLog.Debugf("%s failed for %s@%s",
+		c.netconn.RemoteAddr().String(), user, domain)
 	return 535, "Incorrect user or password"
 }