Phase 6: TCP Server #6

Merged
krendelhoff merged 5 commits from phase-6-tcp-server into master 2025-08-23 08:54:13 +03:00
Showing only changes of commit 8476340f75 - Show all commits

31
internal/server/config.go Normal file
View file

@ -0,0 +1,31 @@
package server
import "time"
// Config holds configuration for the TCP server
type Config struct {
Address string
Timeouts TimeoutConfig
}
// TimeoutConfig holds timeout configuration
type TimeoutConfig struct {
// Read timeout protects against slowloris attacks (clients sending data slowly)
Read time.Duration
// Write timeout protects against slow readers (clients reading responses slowly)
Write time.Duration
// Connection timeout is the maximum total connection lifetime
Connection time.Duration
}
// DefaultConfig returns default server configuration
func DefaultConfig() *Config {
return &Config{
Address: ":8080",
Timeouts: TimeoutConfig{
Read: 5 * time.Second,
Write: 5 * time.Second,
Connection: 15 * time.Second,
},
}
}