mox/smtp/addrlit.go
Mechiel Lukkien cb229cb6cf
mox!
2023-01-30 14:27:06 +01:00

16 lines
255 B
Go

package smtp
import (
"net"
)
// AddressLiteral returns an IPv4 or IPv6 address literal for use in SMTP.
func AddressLiteral(ip net.IP) string {
// ../rfc/5321:2309
s := "["
if ip.To4() == nil {
s += "IPv6:"
}
s += ip.String() + "]"
return s
}