Documentation
¶
Index ¶
- func IsCloudMetadata(ip net.IP) bool
- func IsLinkLocal(ip net.IP) bool
- func IsLoopback(ip net.IP) bool
- func IsPrivate(ip net.IP) bool
- func NewClient(options Options) *http.Client
- func NewSafeTransport(options Options) http.RoundTripper
- func ValidateURL(ctx context.Context, rawURL string, options Options) error
- type BlockedAddressError
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsCloudMetadata ¶ added in v0.28.0
IsCloudMetadata reports whether ip is a cloud instance metadata address outside the link-local ranges, or an IPv6 transition address that embeds one.
func IsLinkLocal ¶ added in v0.27.0
IsLinkLocal reports whether ip is a link-local address or an IPv6 transition address that embeds one.
func IsLoopback ¶ added in v0.27.0
IsLoopback reports whether ip is a loopback address, the unspecified address (which connects to the local host), or an IPv6 transition address that embeds a loopback address. An embedded 0.0.0.0 does not count: a translator would deliver it to its own host, not ours.
func IsPrivate ¶ added in v0.27.0
IsPrivate reports whether ip is a private address or an IPv6 transition address that embeds one.
func NewSafeTransport ¶
func NewSafeTransport(options Options) http.RoundTripper
func ValidateURL ¶ added in v0.27.0
ValidateURL applies the same address policy used when making HTTP requests. Callers must still use a policy-enforcing transport when they connect, since DNS can change between validation and the request.
Types ¶
type BlockedAddressError ¶ added in v0.28.0
BlockedAddressError is returned when a host resolves to an address the options block.
func (*BlockedAddressError) Error ¶ added in v0.28.0
func (e *BlockedAddressError) Error() string
type Options ¶
type Options struct {
BlockLoopback bool
BlockPrivateIP bool
// BlockLinkLocal also blocks the cloud metadata addresses outside the link-local
// ranges (see IsCloudMetadata).
BlockLinkLocal bool
AllowList []string
Timeout time.Duration
Headers http.Header
TokenSource oauth2.TokenSource
// DialRetryTimeout bounds retries of transient TCP failures before any HTTP bytes are sent.
DialRetryTimeout time.Duration
}