Skip to content

Commit

Permalink
client: Add read timeout for initial greeting
Browse files Browse the repository at this point in the history
  • Loading branch information
foxcpp authored and emersion committed Jul 5, 2021
1 parent c11900f commit 26eb481
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ func NewClient(conn net.Conn, host string) (*Client, error) {

c.setConn(conn)

// Initial greeting timeout. RFC 5321 recommends 5 minutes.
c.conn.SetDeadline(time.Now().Add(5 * time.Minute))
defer c.conn.SetDeadline(time.Time{})

_, _, err := c.Text.ReadResponse(220)
if err != nil {
c.Text.Close()
Expand Down

0 comments on commit 26eb481

Please sign in to comment.