Documentation
¶
Index ¶
- func DialPublicHost(ctx context.Context, network, address string) (net.Conn, error)
- func DialPublicHostWithDialer(ctx context.Context, network string, address string, ...) (net.Conn, error)
- func IsBlockedHostnameLiteral(hostname string) bool
- func IsBlockedIP(ip net.IP) bool
- func ResolvePublicHost(ctx context.Context, hostname string) ([]net.IPAddr, error)
- func ResolvePublicHostWithLookup(ctx context.Context, hostname string, ...) ([]net.IPAddr, error)
- func ValidateResolvedPublicHost(ctx context.Context, hostname string) error
- type DestinationPolicy
- func (p DestinationPolicy) DialContext(ctx context.Context, network, address string) (net.Conn, error)
- func (p DestinationPolicy) DialContextWithDialer(ctx context.Context, network string, address string, ...) (net.Conn, error)
- func (p DestinationPolicy) Resolve(ctx context.Context, hostname string) ([]net.IPAddr, error)
- func (p DestinationPolicy) ResolveWithLookup(ctx context.Context, hostname string, ...) ([]net.IPAddr, error)
- type PublicDialer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DialPublicHost ¶
DialPublicHost resolves and dials a host:port address only when all resolved addresses are public.
func DialPublicHostWithDialer ¶
func DialPublicHostWithDialer( ctx context.Context, network string, address string, lookup func(context.Context, string) ([]net.IPAddr, error), dial func(context.Context, string, string) (net.Conn, error), ) (net.Conn, error)
DialPublicHostWithDialer is the testable implementation behind PublicDialer.
func IsBlockedHostnameLiteral ¶
IsBlockedHostnameLiteral reports whether a hostname string is a blocked IP literal. Non-IP hostnames return false because they must be resolved separately.
func IsBlockedIP ¶
IsBlockedIP reports whether an IP falls into blocked non-public or special-use ranges.
func ResolvePublicHost ¶
ResolvePublicHost resolves a hostname once and returns vetted public IP addresses.
func ResolvePublicHostWithLookup ¶
func ResolvePublicHostWithLookup( ctx context.Context, hostname string, lookup func(context.Context, string) ([]net.IPAddr, error), ) ([]net.IPAddr, error)
ResolvePublicHostWithLookup resolves a hostname once with the provided lookup function and returns vetted public IP addresses.
Types ¶
type DestinationPolicy ¶
type DestinationPolicy struct {
AllowPrivateHosts bool
}
DestinationPolicy defines whether a connector may reach private addresses while always resolving the requested hostname and dialing a returned literal IP address.
func NewDestinationPolicy ¶
func NewDestinationPolicy(allowPrivateHosts bool) DestinationPolicy
NewDestinationPolicy creates the shared destination policy used by connector transports.
func (DestinationPolicy) DialContext ¶
func (p DestinationPolicy) DialContext(ctx context.Context, network, address string) (net.Conn, error)
DialContext resolves the requested destination once and dials a vetted literal address. Callers retain the original hostname in protocol configuration so TLS SNI and Host headers continue to identify the intended server.
func (DestinationPolicy) DialContextWithDialer ¶
func (p DestinationPolicy) DialContextWithDialer( ctx context.Context, network string, address string, lookup func(context.Context, string) ([]net.IPAddr, error), dial func(context.Context, string, string) (net.Conn, error), ) (net.Conn, error)
DialContextWithDialer resolves and dials a destination through injectable lookup and dial functions so protocol adapters can prove that the socket never receives the hostname.
func (DestinationPolicy) Resolve ¶
Resolve resolves a hostname under this policy and returns the literal addresses that may be used.
func (DestinationPolicy) ResolveWithLookup ¶
func (p DestinationPolicy) ResolveWithLookup( ctx context.Context, hostname string, lookup func(context.Context, string) ([]net.IPAddr, error), ) ([]net.IPAddr, error)
ResolveWithLookup applies the policy to the supplied DNS lookup result without performing a second resolution, which prevents callers from validating one DNS answer and dialing another.
type PublicDialer ¶
PublicDialer resolves and dials only public IP addresses for host:port targets.
func (PublicDialer) DialContext ¶
DialContext resolves the target host, rejects private/special-use addresses, and dials one of the vetted IPs so the caller cannot re-resolve a different address later.