Also set Peer.TLS connection state on raw TLS connections.
Fix double underscore typo.
This commit is contained in:
parent
52e449011b
commit
722e9f7848
2 changed files with 15 additions and 2 deletions
10
smtpd.go
10
smtpd.go
|
@ -113,7 +113,15 @@ func (srv *Server) newSession(c net.Conn) (s *session) {
|
|||
// Check if the underlying connection is already TLS.
|
||||
// This will happen if the Listerner provided Serve()
|
||||
// is from tls.Listen()
|
||||
__, s.tls = c.(*tls.Conn)
|
||||
|
||||
var tlsConn *tls.Conn
|
||||
|
||||
tlsConn, s.tls = c.(*tls.Conn)
|
||||
|
||||
if s.tls {
|
||||
state := tlsConn.ConnectionState()
|
||||
s.peer.TLS = &state
|
||||
}
|
||||
|
||||
s.scanner = bufio.NewScanner(s.reader)
|
||||
|
||||
|
|
|
@ -1209,7 +1209,12 @@ func TestTLSListener(t *testing.T) {
|
|||
addr := ln.Addr().String()
|
||||
|
||||
server := &smtpd.Server{
|
||||
Authenticator: func(peer smtpd.Peer, username, password string) error { return nil },
|
||||
Authenticator: func(peer smtpd.Peer, username, password string) error {
|
||||
if peer.TLS == nil {
|
||||
t.Error("didn't correctly set connection state on TLS connection")
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
go func() {
|
||||
|
|
Loading…
Add table
Reference in a new issue