diff options
| author | Paul Buetow <paul@buetow.org> | 2026-04-14 10:35:17 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-04-14 10:35:17 +0300 |
| commit | 28b49a9e8bd0190679b8f60019676a1dab2bcfcc (patch) | |
| tree | 16dd065cd1d72b418ed9190abf9778696ff636c8 /internal/daemon/daemon_test.go | |
| parent | 79384e6439c2faf26d68d286a3e814da39e127eb (diff) | |
daemon: set http.Server timeouts for Run (k3)
Configure ReadHeaderTimeout, ReadTimeout, WriteTimeout, and IdleTimeout
on the daemon listener to mitigate slowloris and stuck clients.
Made-with: Cursor
Diffstat (limited to 'internal/daemon/daemon_test.go')
| -rw-r--r-- | internal/daemon/daemon_test.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/internal/daemon/daemon_test.go b/internal/daemon/daemon_test.go index 60c6afa..ccc186e 100644 --- a/internal/daemon/daemon_test.go +++ b/internal/daemon/daemon_test.go @@ -316,6 +316,22 @@ func TestRunEmptyAddr(t *testing.T) { } } +func TestNewDaemonHTTPServerTimeouts(t *testing.T) { + s := newDaemonHTTPServer("127.0.0.1:0", http.NotFoundHandler(), nil) + if g, w := s.ReadHeaderTimeout, 10*time.Second; g != w { + t.Fatalf("ReadHeaderTimeout %v want %v", g, w) + } + if g, w := s.ReadTimeout, 2*time.Minute; g != w { + t.Fatalf("ReadTimeout %v want %v", g, w) + } + if g, w := s.WriteTimeout, 2*time.Minute; g != w { + t.Fatalf("WriteTimeout %v want %v", g, w) + } + if g, w := s.IdleTimeout, 2*time.Minute; g != w { + t.Fatalf("IdleTimeout %v want %v", g, w) + } +} + func TestRunWritesDaemonListenToLogOutput(t *testing.T) { var buf syncBuffer ctx, cancel := context.WithCancel(context.Background()) |
