Documentation
¶
Overview ¶
Package dns provides a local DNS server for dynamic instance resolution. It enables Caddy to resolve instance names to IP addresses at request time.
Index ¶
Constants ¶
View Source
const ( // DefaultPort is the default port for the local DNS server. // Using 0 means the OS will assign a random available port, preventing // conflicts on shared development machines. DefaultPort = 0 // Suffix is the domain suffix used for instance resolution. // Queries like "my-instance.hypeman.internal" will be resolved. Suffix = "hypeman.internal" // DefaultTTL is the TTL for DNS responses in seconds. // Keep it low since instance IPs can change. DefaultTTL = 5 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type InstanceResolver ¶
type InstanceResolver interface {
// ResolveInstanceIP resolves an instance name or ID to its IP address.
ResolveInstanceIP(ctx context.Context, nameOrID string) (string, error)
}
InstanceResolver provides instance IP resolution. This interface is implemented by the instances package.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server provides DNS-based instance resolution for Caddy. It listens on a local port and responds to A record queries for instances in the form "<instance>.hypeman.internal".
func NewServer ¶
func NewServer(resolver InstanceResolver, port int, log *slog.Logger) *Server
NewServer creates a new DNS server for instance resolution. If port is 0, the OS will assign a random available port. The actual port can be retrieved with Port() after Start() is called.
Click to show internal directories.
Click to hide internal directories.