git » chasquid » commit 6747f07

chasquid: Add an expvar to count incoming TLS status

author Alberto Bertogli
2016-10-11 21:58:05 UTC
committer Alberto Bertogli
2016-10-21 21:13:39 UTC
parent eadd0ffc89f993eee52b19457ebbf2276c5b13ad

chasquid: Add an expvar to count incoming TLS status

chasquid.go +6 -0

diff --git a/chasquid.go b/chasquid.go
index 179ad8f..13c4c7a 100644
--- a/chasquid.go
+++ b/chasquid.go
@@ -52,6 +52,7 @@ var (
 	responseCodeCount = expvar.NewMap("chasquid/smtpIn/responseCodeCount")
 	spfResultCount    = expvar.NewMap("chasquid/smtpIn/spfResultCount")
 	loopsDetected     = expvar.NewInt("chasquid/smtpIn/loopsDetected")
+	tlsCount          = expvar.NewMap("chasquid/smtpIn/tlsCount")
 )
 
 func main() {
@@ -798,6 +799,11 @@ func (c *Conn) DATA(params string) (code int, msg string) {
 	}
 
 	c.tr.Debugf("<- 354  You experience a strange sense of peace")
+	if c.onTLS {
+		tlsCount.Add("tls", 1)
+	} else {
+		tlsCount.Add("plain", 1)
+	}
 
 	// Increase the deadline for the data transfer to the connection-level
 	// one, we don't want the command timeout to interfere.