Documentation
¶
Index ¶
- Constants
- Variables
- func Render(answers []Answer, tagHostname bool) string
- func RenderJSON(answers []Answer, q *Query, errs []error) string
- func RenderYAML(answers []Answer, q *Query, errs []error) string
- func RunNXQuery(q *Query) int
- type AAAAData
- type AData
- type Answer
- type CAAData
- type CNAMEData
- type DNSKEYData
- type MXData
- type NSData
- type NSECData
- type Output
- type OutputAnswer
- type OutputError
- type OutputOptions
- type OutputQuery
- type PTRData
- type Query
- type QueryError
- type RRSIGData
- type Resolvers
- type SOAData
- type SRVData
- type TXTData
Constants ¶
const SchemaVersion = 1
SchemaVersion is the JSON output schema version, bumped only for backwards-incompatible changes. Additive changes (new optional fields, new RR types, new error codes) do not bump it.
Variables ¶
var DefaultRRTypes = []string{"A", "AAAA", "MX", "NS", "SOA", "TXT"}
var ErrNXDomain = errors.New("NXDOMAIN")
var ErrServFail = errors.New("SERVFAIL")
var NXTypes = []string{
"MX", "NS", "SOA",
}
var SupportedRRTypes = []string{
"A", "AAAA", "CAA", "CNAME", "DNSKEY", "MX", "NS", "NSEC", "RRSIG", "SOA", "SRV", "TXT",
}
var SupportedUSDs = []string{
"_dmarc", "_domainkey", "_mta-sts",
}
Functions ¶
func Render ¶
Render turns a slice of Answers into the canonical dany text output: one tab-separated `\n`-terminated line per non-PTR Answer, with PTR records folded into their corresponding A/AAAA lines, sorted globally. Exact-duplicate lines are collapsed (relevant when --www queries surface IPs the apex already returned). If tagHostname is true each line is prefixed with the queried hostname and a tab — useful when caller is multiplexing multiple hostnames. Render does no I/O.
func RenderJSON ¶
RenderJSON serializes BuildOutput as a single JSON object terminated by a newline — i.e. ready to concatenate into NDJSON across multiple hostname invocations.
func RenderYAML ¶
RenderYAML serializes BuildOutput as one YAML document prefixed with `---\n`. Concatenating multiple RenderYAML outputs across hostnames yields a well-formed multi-document YAML stream.
Output shape is the same Output envelope used by RenderJSON; the yaml struct tags on the *Data types are kept in lockstep with the json tags (snake_case, same field names) so consumers can swap formats without schema surprises.
func RunNXQuery ¶
RunNXQuery probes q.Hostname across multiple RR types and returns the count of probes that did NOT return NXDOMAIN — i.e. len(types) - nxcount, where types is q.Types if non-empty else NXTypes.
Interpretation:
- 0 — every probe returned NXDOMAIN; hostname is fully NX.
- len(types) — no probe returned NXDOMAIN (either real answers, other errors, or timeouts; we can't distinguish these here).
- in between — partial NXDOMAIN; treated as not-NX by callers (dnx).
Probes that time out or error with anything other than ErrNXDomain are counted as non-NX, so transient failures bias toward "not NX" rather than false-positive NXDOMAIN reports.
NX probes intentionally stay on UDP regardless of q.Udp — responses are tiny and there is no benefit to TCP for this codepath.
Types ¶
type Answer ¶
Answer is a single DNS resource record returned from a typed query. Type is the queried RR type, uppercase ("A", "MX", "TXT", ...) — plus "PTR" for reverse-lookups synthesised when q.Ptr is set. Hostname is the queried hostname (e.g. "example.com", or "_dmarc.example.com" for USD probes; for PTR Answers it is the IP whose PTR was looked up, in dotted/colon form). RR is the raw record from miekg/dns.
func RunQuery ¶
RunQuery fans out concurrent typed DNS lookups for q.Hostname across q.Types (plus USD TXT probes if q.Usd is set, plus A/AAAA probes against www.<q.Hostname> if q.Www is set, plus PTR follow-ups for A/AAAA if q.Ptr is set) and returns the collected Answers and per-query errors. The returned slice is unsorted; pass it through Render for the canonical tab-separated text representation.
On wall-clock timeout (timeoutSeconds), in-flight goroutines' results are silently dropped — they appear as neither Answers nor errors.
type DNSKEYData ¶
type Output ¶
type Output struct {
SchemaVersion int `json:"schema_version" yaml:"schema_version"`
Query OutputQuery `json:"query" yaml:"query"`
Answers []OutputAnswer `json:"answers" yaml:"answers"`
Errors []OutputError `json:"errors" yaml:"errors"`
}
Output is the top-level envelope returned per hostname. Used as the data model for every renderer (JSON, YAML, ...) — see render_json.go / render_yaml.go for the format-specific wrappers around BuildOutput. Stable shape; new fields may be added but existing fields must not be renamed or removed without bumping SchemaVersion.
type OutputAnswer ¶
type OutputAnswer struct {
Type string `json:"type" yaml:"type"`
Name string `json:"name" yaml:"name"`
TTL uint32 `json:"ttl" yaml:"ttl"`
Class string `json:"class" yaml:"class"`
Rdata string `json:"rdata" yaml:"rdata"`
Data interface{} `json:"data" yaml:"data"`
}
OutputAnswer is one DNS resource record. Rdata is the canonical DNS presentation form (always present); Data is the typed per-RR payload — see the per-type *Data structs for shapes.
type OutputError ¶
type OutputError struct {
Type string `json:"type,omitempty" yaml:"type,omitempty"`
Hostname string `json:"hostname,omitempty" yaml:"hostname,omitempty"`
Code string `json:"code" yaml:"code"`
Message string `json:"message" yaml:"message"`
}
OutputError mirrors QueryError for the envelope. Code is a stable machine-readable identifier (e.g. "NXDOMAIN", "SERVFAIL", "EXCHANGE_ERROR", "UNSUPPORTED_TYPE", or "UNKNOWN" for errors lacking a QueryError wrapper). Message preserves the human-readable text.
type OutputOptions ¶
type OutputQuery ¶
type OutputQuery struct {
Hostname string `json:"hostname" yaml:"hostname"`
Types []string `json:"types" yaml:"types"`
Server string `json:"server" yaml:"server"`
Options OutputOptions `json:"options" yaml:"options"`
}
type PTRData ¶
type PTRData struct {
Target string `json:"target" yaml:"target"`
IP string `json:"ip,omitempty" yaml:"ip,omitempty"`
}
PTRData carries Target (the resolved hostname) and IP (the original IP the PTR was queried for, recovered from the in-addr.arpa/ip6.arpa name). IP is empty for PTR records that aren't reverse lookups of an IP.
type Query ¶
type Query struct {
Hostname string
Types []string
Resolvers *Resolvers
Server string
IgnoreErrors bool
Udp bool
Ptr bool
Usd bool
Www bool
// WwwTypes, when non-empty, overrides the default www-probe type set
// (A, AAAA). Only consulted when Www is true. Callers that want the
// www. probe to mirror the user's explicit -t/--types selection set
// this; callers that want the address-only default leave it nil.
WwwTypes []string
Tag bool
}
dany Query - lookup Types for Hostname using Server
type QueryError ¶
QueryError is the structured error type emitted by RunQuery / RunNXQuery goroutines. It carries the RR type and hostname that were being queried plus a stable string Code (DNS rcode names like "NXDOMAIN"/"SERVFAIL", plus "EXCHANGE_ERROR" for transport-level failures and "UNSUPPORTED_TYPE" for unknown RR types) so structured consumers — notably the JSON renderer — can act on errors without parsing the message.
Error() preserves the historical `Error on <type> lookup for "<host>": <…>` format so legacy text consumers and existing substring-based tests keep working. Unwrap exposes the underlying error so errors.Is(err, ErrNXDomain) / ErrServFail continue to match.
func (*QueryError) Error ¶
func (e *QueryError) Error() string
func (*QueryError) Unwrap ¶
func (e *QueryError) Unwrap() error
type RRSIGData ¶
type RRSIGData struct {
TypeCovered string `json:"type_covered" yaml:"type_covered"`
Algorithm uint8 `json:"algorithm" yaml:"algorithm"`
Labels uint8 `json:"labels" yaml:"labels"`
OriginalTTL uint32 `json:"original_ttl" yaml:"original_ttl"`
Expiration string `json:"expiration" yaml:"expiration"`
Inception string `json:"inception" yaml:"inception"`
KeyTag uint16 `json:"key_tag" yaml:"key_tag"`
SignerName string `json:"signer_name" yaml:"signer_name"`
Signature string `json:"signature" yaml:"signature"`
}
type SOAData ¶
type SOAData struct {
MName string `json:"mname" yaml:"mname"`
RName string `json:"rname" yaml:"rname"`
Serial uint32 `json:"serial" yaml:"serial"`
Refresh uint32 `json:"refresh" yaml:"refresh"`
Retry uint32 `json:"retry" yaml:"retry"`
Expire uint32 `json:"expire" yaml:"expire"`
Minimum uint32 `json:"minimum" yaml:"minimum"`
}
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
dany
command
|
|
|
dnx
command
|
|
|
internal
|
|
|
testdns
Package testdns is a tiny in-process DNS server for tests.
|
Package testdns is a tiny in-process DNS server for tests. |
|
version
Package version exposes the current dany release version, embedded from VERSION at compile time.
|
Package version exposes the current dany release version, embedded from VERSION at compile time. |