git » chasquid » commit 5bebb00

smtpsrv: Rename internal variable ehloAddress -> ehloDomain

author Alberto Bertogli
2020-09-14 20:17:01 UTC
committer Alberto Bertogli
2020-09-17 00:29:49 UTC
parent 4c26713f40515953072c235d060cf1261f79903f

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 +9 -9

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)