mhale / smtpd

An SMTP server package written in Go, in the style of the built-in HTTP server.
The Unlicense
397 stars 92 forks source link

Feature request: Connection Timeout #6

Closed egeland closed 7 years ago

egeland commented 7 years ago

It seems like if a client connects, it can stay connected forever - would be good to have a timeout on idle connections. 😅

mhale commented 7 years ago

You're correct, and I like the idea. Thanks. I'll have a look into it.

Ruxton commented 7 years ago

Wouldn't be that difficult to implement in the serve loop ;)

mhale commented 7 years ago

@Ruxton A connection level timeout would be easy - SetDeadline() will take care of that. However, RFC 2821 specifies different timeouts per command, and I like to be RFC compliant, so I want to have a look at how feasible that might be before I commit anything.

mhale commented 7 years ago

@egeland RFC 5321 specifies a minimum server timeout of 5 minutes while waiting for a command, so I will make that the default. Would you prefer it to send a message before disconnecting (and if so, what message?) or just silently close the connection?

egeland commented 7 years ago

I'm not sure what the usual behaviour of SMTP servers are, when closing due to timeout. Might be worth looking at the documentation for postfix or exim..?

mhale commented 7 years ago

Postfix sends "421 4.4.2 [hostname] Error: timeout exceeded" on connection, HELO and DATA timeouts, so I'll follow that example.

mhale commented 7 years ago

I've implemented a connection timeout and there haven't been any complaints so I'm closing this issue.