Commit cac1e161 authored by Alberto Bertogli's avatar Alberto Bertogli

smtpsrv: Set connection deadline before the initial greeting

When handling a connection, today we only set a deadline after each
command received.

However, this does not cover our initial greeting, or the initial TLS
handshake (if the socket is TLS), so a connection can hang
indefininitely at that stage.

This patch fixes that by setting a deadline earlier, before we send or
receive anythong on the connection.
parent ec95131b
......@@ -163,6 +163,10 @@ func (c *Conn) Handle() {
defer"Connected, mode: %s", c.mode)
// Set the first deadline, which covers possibly the TLS handshake and
// then our initial greeting.
if tc, ok := c.conn.(*tls.Conn); ok {
// For TLS connections, complete the handshake and get the state, so
// it can be used when we say hello below.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment