add client timeout via net/Conn SetDeadline

This commit is contained in:
Reese Norris
2025-07-06 17:40:11 -07:00
parent 8c49beeb8c
commit 8affb6210e
4 changed files with 14 additions and 1 deletions

View File

@@ -35,9 +35,11 @@ func (s *Server) handleConn(ctx context.Context, conn net.Conn) {
fmt.Println(err)
}
}()
defer conn.Close()
// Set timeout for login phase
conn.SetDeadline(getTimeBySecondsInFuture(s.cfg.ConnectionTimeoutSeconds))
if err := sendServerIdent(conn); err != nil {
fmt.Printf("Error sending server ident: %v\n", err)
return