Skip to content

Commit 85e1bd1

Browse files
committed
feat: Harden HTTP server security settings
Adjust HTTP server timeouts to better support SSE streaming and improve security. - Set ReadTimeout to 0 to prevent premature disconnection of SSE connections. - Add IdleTimeout to prevent dangling connections. - Set MaxHeaderBytes to a reasonable limit to mitigate memory exhaustion attacks.
1 parent 439f719 commit 85e1bd1

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

internal/flashduty/server.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,10 @@ func RunHTTPServer(cfg HTTPServerConfig) error {
310310
Addr: ":" + cfg.Port,
311311
Handler: mux,
312312
ReadHeaderTimeout: 30 * time.Second,
313-
ReadTimeout: 30 * time.Second,
314-
WriteTimeout: 0, // No timeout for streaming
313+
ReadTimeout: 0, // No timeout for streaming
314+
WriteTimeout: 0, // No timeout for streaming
315+
IdleTimeout: 60 * time.Second, // Prevent dangling connections
316+
MaxHeaderBytes: 128 * 1024, // 128KB
315317
}
316318

317319
go func() {

0 commit comments

Comments
 (0)