smtpclient: expose entire tls connectionstate, not just whether tls was enabled

for moxtools
This commit is contained in:
Mechiel Lukkien
2023-12-11 15:00:58 +01:00
parent f3a35a6766
commit 19d1a8059b
2 changed files with 10 additions and 6 deletions

View File

@ -941,9 +941,13 @@ func (c *Client) SupportsRequireTLS() bool {
return c.extRequireTLS
}
// TLSEnabled returns whether TLS is enabled for this connection.
func (c *Client) TLSEnabled() bool {
return c.tls
// TLSConnectionState returns TLS details if TLS is enabled, and nil otherwise.
func (c *Client) TLSConnectionState() *tls.ConnectionState {
if tlsConn, ok := c.conn.(*tls.Conn); ok {
cs := tlsConn.ConnectionState()
return &cs
}
return nil
}
// Deliver attempts to deliver a message to a mail server.
@ -1140,8 +1144,8 @@ func (c *Client) Botched() bool {
// Close cleans up the client, closing the underlying connection.
//
// If the connection is in initialized and not botched, a QUIT command is sent and
// the response read with a short timeout before closing the underlying connection.
// If the connection is initialized and not botched, a QUIT command is sent and the
// response read with a short timeout before closing the underlying connection.
//
// Close returns any error encountered during QUIT and closing.
func (c *Client) Close() (rerr error) {