Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractHost ¶
ExtractHost extracts and lowercases the host from a URL string. Returns empty string if URL is invalid or has no host.
func ExtractHostname ¶
ExtractHostname extracts the hostname from a host string, removing the port if present. Input is a host string (NOT a full URL), e.g., "example.com:8080" or "example.com". Handles IPv6 addresses correctly - does not strip the port portion of an IPv6 literal.
func IsPrivateIP ¶
IsPrivateIP returns true if the given IP belongs to a private or reserved range.
func IsSameOrigin ¶
IsSameOrigin returns true if hosts are the same domain or one is a subdomain of the other. Strips ports before comparison. Both hosts should already be lowercased.
func ValidateHostNotPrivateIP ¶
ValidateHostNotPrivateIP checks if a hostname is a private IP literal. It does NOT perform DNS resolution -- only rejects IP addresses that parse directly to private ranges. Domain names pass through (use ValidateResolvedIP after DNS resolution for full protection).
func ValidateResolvedIP ¶
ValidateResolvedIP checks if a resolved IP address belongs to a private or reserved range. Use this after DNS resolution to block DNS rebinding attacks.
Types ¶
This section is empty.