Documentation
¶
Index ¶
- Constants
- Variables
- func DeduplicateStrings(strings []string) []string
- func EnsureMemoryHeadroom(maxHeapMB int, configuredContainerMB int) (int, int64)
- func NewSafeHTTPClient(timeout time.Duration, allowPrivate bool) *http.Client
- func ParseMemoryMB(memStr string) (int, error)
- func ValidateIP(ip net.IP, allowPrivate bool) error
- func ValidateURL(rawURL string, allowPrivate bool) (*url.URL, error)
- func ValidateURLStatic(rawURL string, allowPrivate bool) (*url.URL, error)
- type MemoryAllocation
Constants ¶
const ( // OffHeapBufferMB is the minimum off-heap buffer (metaspace, thread stacks, direct buffers, OS overhead) OffHeapBufferMB = 384 // HeadroomRatio is the 25-30% headroom multiplier (1.28 represents 28% headroom) HeadroomRatio = 1.28 )
Variables ¶
Functions ¶
func DeduplicateStrings ¶
func EnsureMemoryHeadroom ¶
EnsureMemoryHeadroom validates that a container memory limit provides the required headroom over maxHeapMB. Returns the safe container memory limit in MB and bytes.
func NewSafeHTTPClient ¶
NewSafeHTTPClient returns an http.Client equipped with SSRF guards at connection time, socket dialing, and redirect following.
func ParseMemoryMB ¶
ParseMemoryMB parses memory string values (e.g. "4096M", "4G", "4096") into megabytes
func ValidateIP ¶
ValidateIP checks whether an IP address belongs to denied ranges (loopback, link-local, private RFC1918)
func ValidateURL ¶
ValidateURL performs static and DNS resolution validation on a URL
func ValidateURLStatic ¶
ValidateURLStatic validates a URL without performing DNS resolution. It enforces the scheme and, when the host is an IP literal, the address policy. Use it where a DNS lookup must not happen (e.g. saving configuration); ValidateURL remains the resolving variant for actual outbound requests.
Types ¶
type MemoryAllocation ¶
type MemoryAllocation struct {
InitMemoryMB int
MaxMemoryMB int
ContainerLimitMB int
InitMemoryStr string
MaxMemoryStr string
ContainerLimitBytes int64
}
MemoryAllocation holds calculated JVM and container memory limits to prevent cgroup OOM kills (exit 137)
func CalculateMemoryAllocation ¶
func CalculateMemoryAllocation(allocatedRAMMB int) MemoryAllocation
CalculateMemoryAllocation calculates dynamic -Xms and -Xmx from total allocated RAM and guarantees container memory limit exceeds JVM -Xmx by 25-30% plus 384MB off-heap buffer.