Documentation
¶
Overview ¶
Package dns emulates Cloud DNS (SRS 5.2): the dns.googleapis.com v1 REST control plane (managed zones, record sets, changes; FR-DNS-001/002) and an authoritative DNS data plane on UDP and TCP that answers from the stored zones and forwards other names to the host resolver (FR-DNS-003/004).
Index ¶
- Variables
- func New(env *emu.Env) emu.Service
- type Service
- func (s *Service) Addr() string
- func (s *Service) ApplySeed(ctx context.Context, section *yaml.Node, baseDir string) error
- func (s *Service) CreateZone(proj string, z *dnsv1.ManagedZone) (*dnsv1.ManagedZone, error)
- func (s *Service) DeleteZone(proj, name string) error
- func (s *Service) EnvVars(gateway string, endpoints map[string]string) map[string]string
- func (s *Service) Name() string
- func (s *Service) Ready() error
- func (s *Service) Register(r emu.Router) error
- func (s *Service) Reset(context.Context) error
- func (s *Service) Resolve(ctx context.Context, name string, qtype uint16) ([]mdns.RR, error)
- func (s *Service) SetAddressMapper(f func(net.IP) net.IP)
- func (s *Service) Start(ctx context.Context) error
- func (s *Service) Stop(ctx context.Context) error
- func (s *Service) UpsertRRSet(proj, zone string, rs *dnsv1.ResourceRecordSet) error
Constants ¶
This section is empty.
Variables ¶
var ( ErrNXDomain = errors.New("dns: name does not exist") ErrRefused = errors.New("dns: query refused") ErrServFail = errors.New("dns: server failure") )
Errors returned by Resolve.
Functions ¶
Types ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the Cloud DNS service module.
func (*Service) CreateZone ¶
func (s *Service) CreateZone(proj string, z *dnsv1.ManagedZone) (*dnsv1.ManagedZone, error)
CreateZone creates a managed zone with its automatic SOA and NS record sets (recorded as change "0", like Cloud DNS). It does not check IAM.
func (*Service) DeleteZone ¶
DeleteZone deletes an empty zone (only the apex SOA and NS remain); otherwise it fails with containerNotEmpty as Cloud DNS does.
func (*Service) EnvVars ¶
EnvVars implements emu.EnvVarer. gcloud's dns client has base URL https://dns.googleapis.com/dns/v1/, so the override includes /dns/v1/.
func (*Service) Register ¶
Register mounts the REST API at /dns/v1/ (root, as the Go client and gcloud address it), under the /dns/ gateway prefix and in host mode.
func (*Service) Reset ¶
Reset drops the in-memory query index; it is rebuilt from the store on the next query.
func (*Service) Resolve ¶
Resolve answers a query the way the data plane would and returns the answer section. A name that does not exist yields ErrNXDomain; a name outside every zone is forwarded (ErrRefused when forwarding is off). NODATA is an empty slice with a nil error. Other services (GKE CoreDNS, LB) use it to resolve emulated names in-process.
func (*Service) SetAddressMapper ¶
SetAddressMapper installs a function that rewrites A record addresses in answers (UDP/TCP server and Resolve): the load balancer maps forwarding rule IPs to the local listeners that serve them (FR-LB-002, FR-INT-004). f returns nil to leave an address unchanged.
func (*Service) Start ¶
Start opens the DNS data plane: TCP via env.Listen("dns") and UDP on the same port number.
func (*Service) UpsertRRSet ¶
func (s *Service) UpsertRRSet(proj, zone string, rs *dnsv1.ResourceRecordSet) error
UpsertRRSet creates or replaces an rrset in a zone as one change. It does not check IAM; other services (e.g. the LB registering A records for forwarding rules) may use it.