Documentation
¶
Overview ¶
Package safefetch validates and downloads external media URLs with SSRF protection.
Index ¶
- Variables
- func CheckHost(ctx context.Context, host string) error
- func FetchURL(ctx context.Context, rawURL string, maxBytes int64) ([]byte, string, error)
- func GuardedDial(d *net.Dialer) func(ctx context.Context, network, addr string) (net.Conn, error)
- func IsProhibitedIP(ip net.IP) bool
- func ParseDataURI(uri string) (string, []byte, error)
- func ValidateMediaMimeType(mime string) error
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func CheckHost ¶ added in v1.4.0
CheckHost fails with ErrProhibitedIP when host is, or resolves to, an address IsProhibitedIP refuses.
func FetchURL ¶
FetchURL downloads external media over HTTPS, enforcing SSRF IP blocking and payload limits.
func GuardedDial ¶ added in v1.4.0
GuardedDial dials like d but refuses a prohibited address. It connects to the address it checked, so a DNS answer cannot change in between.
func IsProhibitedIP ¶
IsProhibitedIP reports whether ip is a loopback, private, link-local, or cloud-metadata address.
func ParseDataURI ¶
ParseDataURI decodes a data URI into its MIME type and payload bytes.
func ValidateMediaMimeType ¶
ValidateMediaMimeType verifies that the MIME type corresponds to supported image, audio, or document formats.
Types ¶
This section is empty.