docs: comprehensive documentation for ExploreDNS
CI / test (pull_request) Failing after 2m13s

- Rewrite README.md with overview, features, installation (go install +
  build from source), quick start, full CLI flag reference table,
  output section descriptions, project structure, and development guide

- Add package-level doc comments to all five internal packages:
  config, dns, fingerprint, output, traverse (via doc.go or existing
  package-declaration files)

- Add GoDoc comments on every exported type, constant, function, and
  method across all packages:
  - internal/config: Config struct fields, all Parse*/Default/Validate
  - internal/dns: QueryConfig, Resolver, BasicResolver, CachingResolver,
    ExchangeFunc, RootServer, RootDiscoveryConfig, DecodedResponse,
    ResponseClassification, all exported helpers
  - internal/fingerprint: Fingerprinter, New, NewWithTimeout, Query,
    FingerprintAll
  - internal/traverse: Traverser, TraverserConfig, TraversalResult,
    Referral, ResolutionState, Response, ResponseType, InfoCache,
    Stack, TraverserHooks, EventStage, TraversalEvent, EventHandler,
    CircularReferralError, UnresolvableNameserverError
  - internal/output: Format, Config, Formatter, SummaryStats,
    NewFormatter, AttachHooks, RunTraversal, DefaultConfig,
    ComputeSummary

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
Gary Hansen
2026-06-08 04:01:51 +10:00
co-authored by Copilot multica-agent
parent fe1afe2a97
commit 9aa85d8e5d
21 changed files with 675 additions and 91 deletions
+32 -5
View File
@@ -11,13 +11,21 @@ import (
miekgdns "github.com/miekg/dns"
)
// TraverserConfig controls the behaviour of a Traverser.
type TraverserConfig struct {
MaxDepth int
QueryType uint16
RootConfig *dns.RootDiscoveryConfig
// MaxDepth caps the traversal depth. Referrals at or beyond this depth
// are rejected and reported as errors.
MaxDepth int
// QueryType is the DNS record type requested at each step (e.g. dns.TypeA).
QueryType uint16
// RootConfig controls how root servers are discovered at startup.
RootConfig *dns.RootDiscoveryConfig
// QueryConfig controls UDP/TCP transport settings for each DNS query.
QueryConfig *dns.QueryConfig
RootAddrs []net.IP
Hooks *TraverserHooks
// RootAddrs may be supplied directly to skip root discovery.
RootAddrs []net.IP
// Hooks receives events during traversal (progress, resolve, result).
Hooks *TraverserHooks
// Fast controls cache sharing across branches. When true (default), child
// branches inherit glue discovered by earlier branches via the shared root
// cache, trading accuracy for speed. When false, each branch gets a
@@ -26,6 +34,8 @@ type TraverserConfig struct {
Fast bool
}
// DefaultTraverserConfig returns a TraverserConfig with sensible defaults:
// max depth 20, query type A, fast mode on.
func DefaultTraverserConfig() *TraverserConfig {
return &TraverserConfig{
MaxDepth: DefaultMaxDepth,
@@ -37,11 +47,17 @@ func DefaultTraverserConfig() *TraverserConfig {
}
}
// TraversalResult pairs a Referral (the query that was attempted) with the
// Response (the outcome of that query). Response may be nil for referrals
// that were never processed (e.g. depth-limit rejections).
type TraversalResult struct {
Referral *Referral
Response *Response
}
// Traverser performs iterative DNS traversal from the root down to the target
// domain, following referrals and CNAME chains.
// Create one with NewTraverser; call Traverse to run a traversal.
type Traverser struct {
config *TraverserConfig
exchange dns.ExchangeFunc
@@ -50,6 +66,8 @@ type Traverser struct {
mu sync.Mutex
}
// NewTraverser creates a Traverser using cfg.
// When cfg is nil, DefaultTraverserConfig is used.
func NewTraverser(cfg *TraverserConfig) *Traverser {
if cfg == nil {
cfg = DefaultTraverserConfig()
@@ -62,10 +80,12 @@ func NewTraverser(cfg *TraverserConfig) *Traverser {
}
}
// SetExchange injects a custom exchange function, primarily for testing.
func (t *Traverser) SetExchange(fn dns.ExchangeFunc) {
t.exchange = fn
}
// SetHooks attaches traversal event hooks to the Traverser.
func (t *Traverser) SetHooks(hooks *TraverserHooks) {
if t.config == nil {
t.config = DefaultTraverserConfig()
@@ -73,6 +93,10 @@ func (t *Traverser) SetHooks(hooks *TraverserHooks) {
t.config.Hooks = hooks
}
// Traverse performs an iterative DNS traversal for name, starting from the root
// servers. It returns all TraversalResults, including intermediate referrals
// and terminal outcomes. Hooks are called for each event during the traversal.
// The context can be used to cancel a long-running traversal.
func (t *Traverser) Traverse(ctx context.Context, name string) ([]TraversalResult, error) {
name = miekgdns.Fqdn(name)
@@ -251,6 +275,9 @@ func (t *Traverser) processReferral(ctx context.Context, ref *Referral, cache *I
}
}
// ResolveNS resolves a nameserver hostname to its IP addresses by performing
// a fresh iterative traversal for that name, using cache to avoid repeated
// queries and visited to detect circular referrals.
func (t *Traverser) ResolveNS(ctx context.Context, nsName string, cache *InfoCache, visited map[string]bool, depth int) ([]net.IP, error) {
if cache != nil {
if addrs := cache.LookupGlue(nsName); len(addrs) > 0 {