Help us shape the future of Go! Take the 2026 Go Developer Survey

util

package
v1.31.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 28, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateHost

func ValidateHost(hostname string, opts ...HostValidationOption) error

ValidateHost checks that the hostname is resolvable and that none of the addresses it resolves to are ones a warehouse connection should ever reach.

Rejected: unspecified (0.0.0.0, ::), loopback, link-local — which covers the instance metadata endpoint 169.254.169.254 — multicast, and AWS's reserved prefix for instance metadata over IPv6.

Private RFC1918/ULA space is deliberately NOT rejected. Warehouses reached over AWS PrivateLink resolve to a private address in the customer's VPC, so rejecting private space would break every such connection. Those ranges are customer-chosen and can overlap our own, which means they cannot be told apart from in-cluster addresses by inspecting the IP alone — blocking in-cluster services needs an operator-supplied CIDR list instead, which is tracked separately.

Note this cannot defend against DNS rebinding: the address checked here is not necessarily the address dialled later. It raises the bar for a caller-supplied host without claiming to close that gap.

Types

type HostValidationOption added in v1.30.0

type HostValidationOption func(*hostValidationOptions)

HostValidationOption customises ValidateHost.

func AllowLoopback added in v1.30.0

func AllowLoopback(allow bool) HostValidationOption

AllowLoopback permits hosts that resolve to loopback addresses when allow is true, and is a no-op otherwise, so callers can pass a flag through directly.

Intended only for tests that run against a database in a local container. It deliberately relaxes nothing else: link-local, multicast and unspecified addresses stay rejected, so this cannot be used to reach cloud metadata.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL