Fix client IP in Received line for IPv6 IP addresses

This commit is contained in:
Bernhard Froehlich 2018-12-14 11:08:42 +00:00
parent 9fccea2351
commit e7d1686eae
No known key found for this signature in database
GPG key ID: 4DD88C3F9F3B8333

View file

@ -3,7 +3,7 @@ package smtpd
import (
"crypto/tls"
"fmt"
"strings"
"net"
"time"
)
@ -34,10 +34,15 @@ func (env *Envelope) AddReceivedLine(peer Peer) {
)
}
peerIP := ""
if addr, ok := peer.Addr.(*net.TCPAddr); ok {
peerIP = addr.IP.String()
}
line := wrap([]byte(fmt.Sprintf(
"Received: from %s [%s] by %s with %s;%s\r\n\t%s\r\n",
peer.HeloName,
strings.Split(peer.Addr.String(), ":")[0],
peerIP,
peer.ServerName,
peer.Protocol,
tlsDetails,