Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatBytes ¶
FormatBytes converts bytes to human-readable format
func InitCPU ¶
func InitCPU(lim Limits)
InitCPU sets GOMAXPROCS based on config This prevents the Go server from consuming all CPU cores
func InitMemory ¶
func InitMemory(lim Limits)
InitMemory sets memory limit based on config Uses runtime/debug SetMemoryLimit (Go 1.19+)
Types ¶
type Limits ¶
type Limits struct {
// GOMAXPROCS limit (CPU cores)
GoMaxProcs int // default: 2
// Connection limits
MaxConcurrentConns int // default: 100
MaxConnsPerIP int // default: 10
// Request limits
RequestTimeoutSec int // default: 30
MaxRequestBodyMB int // default: 10
MaxRequestBodyBytes int64 // computed from MB
// Rate limiting
RateLimitPerMin int // default: 60 requests per minute per IP
// Memory limits
MaxMemoryPercent int // default: 20% of available
MaxMemoryBytes int64 // default: 512 MiB
// Logging
EnableMetrics bool // default: true
}
Limits holds all safety thresholds for the GUI server
type MemAvail ¶
MemAvail holds available memory info (cgroup-aware) This matches the pattern from go-feeds/internal/safety/mem.go
func AvailableMem ¶
func AvailableMem() MemAvail
AvailableMem returns available memory (cgroup-aware for containers) This is critical for running in Docker/Kubernetes where cgroup limits apply
type SystemIPs ¶
type SystemIPs struct {
ServerIPs []net.IP // All server interface IPs
CurrentUserIP net.IP // IP of current SSH connection
GatewayIPs []net.IP // Default gateway
DNSServers []net.IP // DNS servers from /etc/resolv.conf
LoopbackCIDRs []net.IPNet // 127.0.0.0/8, ::1/128
}
SystemIPs holds all critical IPs that must NEVER be blocked
func DetectSystemIPs ¶
DetectSystemIPs auto-detects all critical IPs that must be whitelisted
func (*SystemIPs) GetAllIPsWithCIDRs ¶
GetAllIPsWithCIDRs returns all IPs including loopback CIDRs
func (*SystemIPs) PrintSystemIPs ¶
func (s *SystemIPs) PrintSystemIPs()
PrintSystemIPs displays all detected IPs