Documentation
¶
Index ¶
- func DefaultLookupIP(ctx context.Context, host string) ([]net.IP, error)
- func FilterAllowedIPs(ips []net.IP) ([]net.IP, error)
- func IsBlockedIP(ip net.IP) bool
- func NewHTTPClient(timeout time.Duration, lookup LookupIPFunc) *http.Client
- func SafeDialContext(lookup LookupIPFunc) func(ctx context.Context, network, addr string) (net.Conn, error)
- func ValidateURL(raw string) error
- type LookupIPFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultLookupIP ¶
DefaultLookupIP uses the system resolver.
func FilterAllowedIPs ¶
FilterAllowedIPs returns only public IPs. If any resolved address is blocked, or none remain, it returns an error (strict: mixed A/AAAA sets are rejected).
func IsBlockedIP ¶
IsBlockedIP reports whether ip is unsuitable for outbound webhook destinations (loopback, RFC1918, link-local, ULA, unspecified, multicast, IANA special-purpose IPv4 including CGNAT/TEST-NET/benchmarking/reserved, NAT64).
func NewHTTPClient ¶
func NewHTTPClient(timeout time.Duration, lookup LookupIPFunc) *http.Client
NewHTTPClient builds an http.Client that dials only SSRF-safe addresses. Redirects are disabled. Environment HTTP(S)_PROXY is ignored (egress proxy is out of scope — honoring it would skip destination IP checks).
Uses a dedicated Transport (not a Clone of http.DefaultTransport) so inherited DialTLS / DialTLSContext hooks cannot bypass SafeDialContext.
func SafeDialContext ¶
func SafeDialContext(lookup LookupIPFunc) func(ctx context.Context, network, addr string) (net.Conn, error)
SafeDialContext returns a DialContext that resolves via lookup, rejects any blocked address, and connects only to an allowed IP (DNS-rebinding safe).
func ValidateURL ¶
ValidateURL checks scheme/host and rejects literal / non-canonical blocked IPs. Hostnames are not resolved here — callers that dial must use SafeDialContext.