From 5bebb00af9b6ac301acfdc79a16d314842c3df3f Mon Sep 17 00:00:00 2001 From: Alberto Bertogli Date: Mon, 14 Sep 2020 21:17:01 +0100 Subject: [PATCH] smtpsrv: Rename internal variable ehloAddress -> ehloDomain The EHLO parameter is generally referred to as "domain", even though it can take either a domain or an address. For clarity, rename the variable and comments to match. This is stylistic only, there are no functional changes. --- internal/smtpsrv/conn.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/internal/smtpsrv/conn.go b/internal/smtpsrv/conn.go index a35677f..891d98b 100644 --- a/internal/smtpsrv/conn.go +++ b/internal/smtpsrv/conn.go @@ -115,8 +115,8 @@ type Conn struct { // TLS configuration. tlsConfig *tls.Config - // Address given at HELO/EHLO, used for tracing purposes. - ehloAddress string + // Domain given at HELO/EHLO. + ehloDomain string // Envelope. mailFrom string @@ -305,7 +305,7 @@ func (c *Conn) HELO(params string) (code int, msg string) { if len(strings.TrimSpace(params)) == 0 { return 501, "Invisible customers are not welcome!" } - c.ehloAddress = strings.Fields(params)[0] + c.ehloDomain = strings.Fields(params)[0] types := []string{ "general store", "used armor dealership", "second-hand bookstore", @@ -323,7 +323,7 @@ func (c *Conn) EHLO(params string) (code int, msg string) { if len(strings.TrimSpace(params)) == 0 { return 501, "Invisible customers are not welcome!" } - c.ehloAddress = strings.Fields(params)[0] + c.ehloDomain = strings.Fields(params)[0] c.isESMTP = true buf := bytes.NewBuffer(nil) @@ -575,7 +575,7 @@ func (c *Conn) RCPT(params string) (code int, msg string) { // DATA SMTP command handler. func (c *Conn) DATA(params string) (code int, msg string) { - if c.ehloAddress == "" { + if c.ehloDomain == "" { return 503, "5.5.1 Invisible customers are not welcome!" } if c.mailFrom == "" { @@ -669,15 +669,15 @@ func (c *Conn) addReceivedHeader() { // https://tools.ietf.org/html/rfc5321#section-4.4 if c.completedAuth { - // For authenticated users, only show the EHLO address they gave; + // For authenticated users, only show the EHLO domain they gave; // explicitly hide their network address. - v += fmt.Sprintf("from %s\n", c.ehloAddress) + v += fmt.Sprintf("from %s\n", c.ehloDomain) } else { // For non-authenticated users we show the real address as canonical, - // and then the given EHLO address for convenience and + // and then the given EHLO domain for convenience and // troubleshooting. v += fmt.Sprintf("from [%s] (%s)\n", - addrLiteral(c.conn.RemoteAddr()), c.ehloAddress) + addrLiteral(c.conn.RemoteAddr()), c.ehloDomain) } v += fmt.Sprintf("by %s (chasquid) ", c.hostname)