Documentation
¶
Overview ¶
Package outboundpolicy defines the shared destination boundary for outbound network clients.
Index ¶
- Variables
- func IsExplicitLoopbackHost(host string) bool
- func NewHTTPClient(base *http.Client, policy Policy, timeout time.Duration, maxRedirects int) *http.Client
- func SameOrigin(left, right *url.URL) bool
- type Dialer
- type NetworkDialer
- type Policy
- func (p Policy) IsTrustedOrigin(destination *url.URL) bool
- func (p Policy) ValidateResolvedAddresses(addresses []netip.Addr, host string, port string) error
- func (p Policy) ValidateURL(destination *url.URL) error
- func (p Policy) WithCredentialOrigin(raw string) (Policy, error)
- func (p Policy) WithTrustedOrigin(raw string) (Policy, error)
- type Resolver
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidURL reports a URL that cannot be used as an outbound destination. ErrInvalidURL = errors.New("outbound policy: invalid destination URL") // ErrInsecureTransport reports HTTP used outside an explicitly trusted origin or loopback allowance. ErrInsecureTransport = errors.New("outbound policy: HTTPS is required for untrusted destinations") // ErrBlockedDestination reports an address outside the configured destination policy. ErrBlockedDestination = errors.New("outbound policy: destination is blocked") )
Functions ¶
func IsExplicitLoopbackHost ¶
IsExplicitLoopbackHost recognizes literal and reserved-name loopback destinations.
func NewHTTPClient ¶
func NewHTTPClient(base *http.Client, policy Policy, timeout time.Duration, maxRedirects int) *http.Client
NewHTTPClient clones a client and installs URL, redirect, and dial-time policy. A custom non-*http.Transport RoundTripper remains the explicit owner of its connection boundary.
func SameOrigin ¶
SameOrigin compares normalized scheme, hostname, and effective port.
Types ¶
type Dialer ¶
type Dialer struct {
// contains filtered or unexported fields
}
Dialer validates the complete DNS answer immediately before connecting to a pinned IP.
type NetworkDialer ¶
NetworkDialer establishes one connection to an already-approved IP address.
type Policy ¶
type Policy struct {
// contains filtered or unexported fields
}
Policy validates URL and resolved-address destinations. Values are immutable after construction.
func (Policy) IsTrustedOrigin ¶
IsTrustedOrigin reports whether a URL matches one exact operator-owned origin.
func (Policy) ValidateResolvedAddresses ¶
ValidateResolvedAddresses rejects a complete DNS answer when any address violates the policy for the exact destination host and port.
func (Policy) ValidateURL ¶
ValidateURL applies scheme, origin, and literal-address policy before a request is sent.
func (Policy) WithCredentialOrigin ¶
WithCredentialOrigin returns a copy that permits credential forwarding to one exact public HTTPS origin without granting access to private resolved addresses.
func (Policy) WithTrustedOrigin ¶
WithTrustedOrigin returns a copy that permits one exact operator-owned HTTP(S) origin, including its resolved private addresses and credential forwarding. The URL must not contain credentials or a fragment.