Documentation
¶
Overview ¶
Package zone provides DNS zone management and query handling.
Index ¶
- Variables
- type Config
- type CreateConfig
- type Deletion
- type LoadConfig
- type Manager
- func (m *Manager) Close() error
- func (m *Manager) Count() int
- func (m *Manager) Create(ctx context.Context, cfg CreateConfig) (*Zone, error)
- func (m *Manager) Delete(ctx context.Context, name domainname.DomainName) error
- func (m *Manager) Find(name domainname.DomainName) (*Zone, error)
- func (m *Manager) Get(name domainname.DomainName) (*Zone, error)
- func (m *Manager) List() []domainname.DomainName
- func (m *Manager) Open(ctx context.Context) error
- func (m *Manager) SetSigner(name domainname.DomainName, sgn *signer.Signer) error
- func (m *Manager) Store() *store.Store
- type ManagerConfig
- type OpenOption
- type QueryOption
- type QueryResult
- type Section
- type Zone
- func Load(ctx context.Context, cfg LoadConfig) (*Zone, error)
- func LoadIntoManager(ctx context.Context, mgr *Manager, filePath, origin string) (*Zone, error)
- func New(ctx context.Context, cfg Config) (*Zone, error)
- func Open(ctx context.Context, st *store.Store, name string, sgn *signer.Signer, ...) (*Zone, error)
- func (z *Zone) Add(ctx context.Context, rr mindnspb.ProtoRR) error
- func (z *Zone) Apply(ctx context.Context, additions []mindnspb.ProtoRR, deletions []Deletion) error
- func (z *Zone) BatchUpdate(ctx context.Context, req *mindnspb.BatchUpdateRequest) (*mindnspb.BatchUpdateResponse, error)
- func (z *Zone) DS() *dns.DS
- func (z *Zone) Delete(ctx context.Context, name domainname.DomainName, rrtype mindnspb.Type) error
- func (z *Zone) DeleteRRset(ctx context.Context, name domainname.DomainName, rrtype mindnspb.Type) error
- func (z *Zone) GetRRset(ctx context.Context, name domainname.DomainName, rrtype mindnspb.Type) ([]mindnspb.ProtoRR, error)
- func (z *Zone) IsSigned() bool
- func (z *Zone) ListRRsets(ctx context.Context, nameFilter string, typeFilter mindnspb.Type) ([]*mindnspb.RRset, error)
- func (z *Zone) Name() domainname.DomainName
- func (z *Zone) Query(ctx context.Context, qst *mindnspb.Question, opts ...QueryOption) (*QueryResult, error)
- func (z *Zone) SOA(ctx context.Context) (*mindnspb.SOA, error)
- func (z *Zone) Serial(ctx context.Context) (uint32, error)
- func (z *Zone) SetRRset(ctx context.Context, name domainname.DomainName, rrtype mindnspb.Type, ...) error
- func (z *Zone) Signer() *signer.Signer
- func (z *Zone) Store() *store.Store
Constants ¶
This section is empty.
Variables ¶
var ( ErrNonExistentDomain = errors.New("non-existent domain") ErrNonExistentRRset = errors.New("non-existent rrset") ErrZoneNotFound = errors.New("zone not found") )
var ( ErrSOAAtApexOnly = errors.New("zone: SOA record only allowed at zone apex") ErrCNAMEAtApex = errors.New("zone: CNAME not allowed at zone apex") ErrMultipleCNAME = errors.New("zone: only one CNAME allowed per name") ErrALIASCoexistence = errors.New("zone: ALIAS cannot coexist with A/AAAA records") ErrALIASNotAtApex = errors.New("zone: ALIAS is primarily for zone apex, consider using CNAME") )
Validation errors
var ( ErrNotInZone = errors.New("zone: name not in zone") ErrInvalidRecord = errors.New("zone: invalid record") ErrCNAMECoexistence = errors.New("zone: CNAME cannot coexist with other records") ErrDuplicate = errors.New("zone: duplicate record") )
Common errors
var ( // ErrNoSOA is returned when a zone file does not contain a SOA record. ErrNoSOA = errors.New("zone file has no SOA record") )
Functions ¶
This section is empty.
Types ¶
type Config ¶ added in v0.5.0
type Config struct {
// Name is the zone's domain name (e.g., "example.com.")
Name string
// Store is the backing store (required)
Store *store.Store
// SOA parameters
PrimaryNS string // Primary nameserver (e.g., "ns1.example.com.")
AdminMbox string // Admin mailbox (e.g., "admin.example.com.")
// Optional configuration
DefaultTTL uint32 // Default TTL for records (default: 3600)
SOARefresh uint32 // SOA refresh interval (default: 7200)
SOARetry uint32 // SOA retry interval (default: 3600)
SOAExpire uint32 // SOA expire time (default: 1209600)
SOAMinTTL uint32 // SOA minimum TTL (default: 3600)
RRSIGValidity time.Duration // RRSIG validity period (default: 30 days)
// DNSSEC (optional - nil for unsigned zones)
Signer *signer.Signer
// ALIAS resolution (optional - nil disables ALIAS support)
ALIASResolver *alias.Resolver
}
Config holds zone configuration.
type CreateConfig ¶ added in v0.5.0
type CreateConfig struct {
// Name is the zone's domain name (e.g., "example.com.")
Name string
// SOA parameters
PrimaryNS string // Primary nameserver (e.g., "ns1.example.com.")
AdminMbox string // Admin mailbox (e.g., "admin.example.com.")
// Optional configuration
DefaultTTL uint32 // Default TTL for records (default: 3600)
SOARefresh uint32 // SOA refresh interval (default: 7200)
SOARetry uint32 // SOA retry interval (default: 3600)
SOAExpire uint32 // SOA expire time (default: 1209600)
SOAMinTTL uint32 // SOA minimum TTL (default: 3600)
// DNSSEC (optional - nil for unsigned zones)
Signer *signer.Signer
}
CreateConfig holds configuration for creating a new zone.
type Deletion ¶ added in v0.5.0
type Deletion struct {
Name domainname.DomainName
Type mindnspb.Type
}
Deletion represents a record deletion request.
type LoadConfig ¶ added in v0.5.0
type LoadConfig struct {
// FilePath is the path to the zone file.
FilePath string
// Origin is the zone origin (e.g., "example.com.").
// If empty, will be inferred from the SOA record.
Origin string
// Store is the store to use for the zone.
Store *store.Store
}
LoadConfig configures zone loading from a file.
type Manager ¶ added in v0.5.0
type Manager struct {
// contains filtered or unexported fields
}
Manager manages all DNS zones backed by a single store. It serves as the single source of truth for zone data.
func NewManager ¶ added in v0.5.0
func NewManager(cfg ManagerConfig) (*Manager, error)
NewManager creates a new zone manager. Call Open() to load existing zones from the store.
func (*Manager) Close ¶ added in v0.5.0
Close closes the manager. Currently a no-op but reserved for future cleanup.
func (*Manager) Delete ¶ added in v0.5.0
func (m *Manager) Delete(ctx context.Context, name domainname.DomainName) error
Delete removes a zone from the store and cache.
func (*Manager) Find ¶ added in v0.5.0
func (m *Manager) Find(name domainname.DomainName) (*Zone, error)
Find finds the most specific zone for a domain name. It walks up the domain tree until it finds a matching zone.
func (*Manager) Get ¶ added in v0.5.0
func (m *Manager) Get(name domainname.DomainName) (*Zone, error)
Get returns a zone by exact name match.
func (*Manager) List ¶ added in v0.5.0
func (m *Manager) List() []domainname.DomainName
List returns all zone names.
func (*Manager) Open ¶ added in v0.5.0
Open loads all existing zones from the store into memory. This should be called after NewManager to populate the cache.
func (*Manager) SetSigner ¶ added in v0.5.0
func (m *Manager) SetSigner(name domainname.DomainName, sgn *signer.Signer) error
SetSigner sets the DNSSEC signer for a zone. This is separate from Create because signers may need to be configured after loading zones from the store.
type ManagerConfig ¶ added in v0.5.0
type ManagerConfig struct {
// Store is the backing BadgerDB store (required).
Store *store.Store
// ALIASResolver is the shared resolver for ALIAS records (optional).
ALIASResolver *alias.Resolver
}
ManagerConfig configures the ZoneManager.
type OpenOption ¶ added in v0.5.0
type OpenOption func(*Zone)
OpenOption configures an opened zone.
func WithALIASResolver ¶ added in v0.5.0
func WithALIASResolver(r *alias.Resolver) OpenOption
WithALIASResolver sets the ALIAS resolver for the zone.
type QueryOption ¶ added in v0.4.2
type QueryOption func(*queryOptions)
func QueryWithDNSSEC ¶ added in v0.4.2
func QueryWithDNSSEC() QueryOption
type QueryResult ¶ added in v0.4.2
type Zone ¶
type Zone struct {
// contains filtered or unexported fields
}
Zone represents a DNS zone with query and mutation capabilities.
func Load ¶ added in v0.5.0
func Load(ctx context.Context, cfg LoadConfig) (*Zone, error)
Load parses a zone file and creates a zone with all records. Returns the loaded zone and any error encountered.
func LoadIntoManager ¶ added in v0.5.0
LoadIntoManager parses a zone file and loads it into a Manager. The zone is added to the manager's cache after loading.
func Open ¶ added in v0.5.0
func Open(ctx context.Context, st *store.Store, name string, sgn *signer.Signer, opts ...OpenOption) (*Zone, error)
Open opens an existing zone from the store.
func (*Zone) Apply ¶ added in v0.5.0
Apply applies multiple additions and deletions atomically. For signed zones, the zone is re-signed after mutations.
func (*Zone) BatchUpdate ¶ added in v0.5.0
func (z *Zone) BatchUpdate(ctx context.Context, req *mindnspb.BatchUpdateRequest) (*mindnspb.BatchUpdateResponse, error)
BatchUpdate applies a batch of changes atomically with precondition checks. TODO: Implement precondition checking and atomic application.
func (*Zone) DS ¶ added in v0.5.0
DS returns the DS record for the zone's KSK (for signed zones only).
func (*Zone) Delete ¶ added in v0.5.0
func (z *Zone) Delete(ctx context.Context, name domainname.DomainName, rrtype mindnspb.Type) error
Delete removes an RRset from the zone. For signed zones, this triggers re-signing.
func (*Zone) DeleteRRset ¶ added in v0.5.0
func (z *Zone) DeleteRRset(ctx context.Context, name domainname.DomainName, rrtype mindnspb.Type) error
DeleteRRset removes an RRset from the zone.
func (*Zone) GetRRset ¶ added in v0.5.0
func (z *Zone) GetRRset(ctx context.Context, name domainname.DomainName, rrtype mindnspb.Type) ([]mindnspb.ProtoRR, error)
GetRRset returns an RRset from the zone.
func (*Zone) IsSigned ¶ added in v0.5.0
IsSigned returns true if this zone has DNSSEC signing enabled.
func (*Zone) ListRRsets ¶ added in v0.5.0
func (z *Zone) ListRRsets(ctx context.Context, nameFilter string, typeFilter mindnspb.Type) ([]*mindnspb.RRset, error)
ListRRsets returns all RRsets in the zone, optionally filtered by name and type.
func (*Zone) Name ¶ added in v0.5.0
func (z *Zone) Name() domainname.DomainName
Name returns the zone's domain name.
func (*Zone) Query ¶ added in v0.4.2
func (z *Zone) Query(ctx context.Context, qst *mindnspb.Question, opts ...QueryOption) (*QueryResult, error)
func (*Zone) SetRRset ¶ added in v0.5.0
func (z *Zone) SetRRset(ctx context.Context, name domainname.DomainName, rrtype mindnspb.Type, rrs []mindnspb.ProtoRR) error
SetRRset replaces an RRset in the zone.