Documentation
¶
Overview ¶
Package xfr implements DNS zone transfer clients: AXFR (RFC 5936), IXFR (RFC 1995), over plain TCP or TLS (RFC 9103), authenticated with TSIG (RFC 8945).
AXFR ¶
A full transfer is a stream of DNS messages over one TCP connection. It opens with the zone's SOA and closes with the same SOA repeated; everything between is the zone. The repeated SOA is the only end-of-stream marker — there is no length, no count, and no terminator — so a client that does not track it correctly either truncates a zone silently or hangs waiting for data that will never come.
IXFR ¶
An incremental transfer (RFC 1995) asks "what changed since serial N?" and carries only the difference. The server may answer three different ways to the same query, distinguishable only by inspecting the record stream:
up to date a single SOA whose serial equals the client's
incremental SOA(new), then alternating delete/add sections per version
full an ordinary AXFR-shaped response, when the server has no
history far enough back to answer incrementally
The third case is not an error and not signalled anywhere in the header. A client that assumes its IXFR query produced an IXFR-shaped answer will misparse a perfectly valid full transfer as a nonsensical delta.
TSIG ¶
Zone data is not public in the way ordinary DNS answers are, and a transfer carries the entire contents of a zone. TSIG authenticates both the request (so a primary can refuse strangers) and every message of the response stream, chained so the stream cannot be truncated or reordered mid-flight.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoPrimary = errors.New("xfr: primary address is required") ErrNoSOA = errors.New("xfr: no SOA record in transfer response") ErrTXIDMismatch = errors.New("xfr: response transaction ID does not match the query") ErrQuestionMatch = errors.New("xfr: response question does not match the query") ErrTooManyRecs = errors.New("xfr: transfer exceeded the record limit") ErrRcode = errors.New("xfr: primary refused the transfer") )
Functions ¶
func AXFR ¶
func AXFR(ctx context.Context, cfg ClientConfig) ([]dns.ResourceRecord, error)
AXFR performs a full zone transfer.
Types ¶
type ClientConfig ¶
type ClientConfig struct {
// PrimaryAddr is the primary server, e.g. "10.0.0.1" or "10.0.0.1:853".
// The port defaults to 853 with TLS and 53 without.
PrimaryAddr string
// Zone is the zone to transfer, e.g. "example.com".
Zone string
// Timeout is the per-message read/write deadline.
Timeout time.Duration
// UseTLS enables XFR-over-TLS (RFC 9103).
UseTLS bool
// TLSServerName is the name to verify the primary's certificate
// against. Required when UseTLS is set and InsecureSkipVerify is not:
// a bare IP address has nothing to verify against.
TLSServerName string
// InsecureSkipVerify disables certificate verification. Test use only;
// it turns RFC 9103's transport security into transport obfuscation.
InsecureSkipVerify bool
// TSIGKey authenticates the transfer (RFC 8945). Zero value disables
// TSIG, which is appropriate only when the primary restricts transfers
// by source address instead.
TSIGKey dns.TSIGKey
// TSIGFudge is the permitted clock skew in seconds. 0 uses the RFC 8945
// recommended 300.
TSIGFudge uint16
}
ClientConfig configures a zone transfer.
type Delta ¶ added in v0.8.33
type Delta struct {
FromSerial uint32
ToSerial uint32
Deleted []dns.ResourceRecord
Added []dns.ResourceRecord
}
Delta is one version step of an incremental transfer: the records removed and added between two serials (RFC 1995 §2).
type Result ¶ added in v0.8.33
type Result struct {
// Incremental reports whether the server answered with deltas. A false
// value after an IXFR request is normal and means the server fell back
// to a full transfer (RFC 1995 §2) — Records then holds the whole zone.
Incremental bool
// UpToDate reports that the client's serial was already current, so
// there is nothing to apply. RFC 1995 §2 signals this with a response
// containing only the SOA.
UpToDate bool
// Records is the complete zone, set for a full transfer.
Records []dns.ResourceRecord
// Deltas holds the version steps, set for an incremental transfer.
Deltas []Delta
// Serial is the zone serial after applying the transfer.
Serial uint32
}
Result is the outcome of a transfer.
func IXFR ¶ added in v0.8.33
IXFR requests the changes since `serial` (RFC 1995).
The caller must handle all three shapes the server may answer with — see Result. In particular a non-incremental Result is not a failure: it is the server saying "I cannot go back that far, here is everything", which is the normal outcome when a secondary has been offline longer than the primary keeps history for.