Documentation
¶
Overview ¶
Package httpsafe provides SSRF-safe HTTP helpers for the adapters. It centralises the host-allowlist check and a CheckRedirect hook so every crawl client applies the same policy.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var LookupHostIPs = func(ctx context.Context, host string) ([]net.IP, error) { addrs, err := net.DefaultResolver.LookupIPAddr(ctx, host) if err != nil { return nil, err } out := make([]net.IP, len(addrs)) for i, a := range addrs { out[i] = a.IP } return out, nil }
LookupHostIPs is overridable for tests. Production calls resolve via net.DefaultResolver.
Functions ¶
func AllowedHost ¶
AllowedHost reports whether u's host is safe to connect to. Hostnames are resolved and every returned IP is checked against the blocklist (loopback, link-local, RFC1918, carrier-grade NAT, cloud-metadata ranges, IPv6 unique-local). Unresolvable hosts fail closed.
Types ¶
This section is empty.