Documentation
¶
Overview ¶
Package safefetch is the outbound-network guard shared by plugin http.fetch and the WordPress importer: it resolves a host itself, refuses private, loopback, link-local, metadata and other non-public addresses, and connects to the checked IP literal so DNS cannot answer differently between the check and the connect (rebinding).
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrBlocked = errors.New("fetch blocked")
ErrBlocked is wrapped by every policy refusal (address, scheme, redirect).
Functions ¶
func BlockedAddr ¶
BlockedAddr reports whether a connection to ip must be refused.
func CheckScheme ¶
CheckScheme refuses anything but http and https, and credentials in the URL.
func DefaultLookup ¶
DefaultLookup uses the system resolver.
func NewClient ¶
func NewClient(o ClientOptions) *http.Client
NewClient returns an http.Client whose every connection (and every redirect hop, which must stay on http/https) goes through the Dialer guard.
Types ¶
type ClientOptions ¶
type ClientOptions struct {
AllowPrivate bool
Lookup Lookup
Timeout time.Duration // per request; 0 means 30s
MaxRedirects int // 0 means 5
}
ClientOptions configures NewClient.