Documentation
¶
Overview ¶
Package metadataurl provides bounded, read-only checks for public metadata URL destinations.
Index ¶
- Constants
- Variables
- func CheckAll(ctx context.Context, checker Checker, rawURLs []string) (map[string]Outcome, error)
- func IsHTTPURL(parsed *url.URL) bool
- func IsPublicIP(address netip.Addr) bool
- func NewHTTPClient() *http.Client
- func PublicDialControl(_ context.Context, _, address string, _ syscall.RawConn) error
- func RedirectPolicy(req *http.Request, via []*http.Request) error
- type Checker
- type Outcome
- type Result
Constants ¶
const ( // CheckConcurrency bounds simultaneous destination requests. CheckConcurrency = 4 // CheckTimeout bounds each destination request when no ASC timeout override // is configured. CheckTimeout = 10 * time.Second // MaxRedirects bounds the number of HTTP(S) redirects followed. MaxRedirects = 10 )
Variables ¶
var ErrUnsafeTarget = errors.New("metadata URL target is not a public internet address")
ErrUnsafeTarget reports a destination that is not safe to contact as a public metadata URL.
Functions ¶
func CheckAll ¶
CheckAll checks each unique, trimmed URL once, with bounded concurrency. The returned map is keyed by the trimmed URL supplied to the checker. An individual request failure is retained in Outcome and does not abort the remaining checks. Context cancellation is returned to the caller.
func IsPublicIP ¶
IsPublicIP reports whether address is suitable for an outbound metadata destination.
func NewHTTPClient ¶
NewHTTPClient returns the configured bounded HTTP client. It is exported for compatibility adapters and tests that need to inject a custom transport.
func PublicDialControl ¶
PublicDialControl rejects every resolved non-public address, including addresses that otherwise look global-unicast but belong to special-purpose IANA ranges.