- 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:
co-authored by
Copilot
multica-agent
parent
fe1afe2a97
commit
9aa85d8e5d
@@ -1,12 +1,18 @@
|
||||
package traverse
|
||||
|
||||
// DefaultMaxDepth is the maximum traversal depth used when no explicit depth is configured.
|
||||
const DefaultMaxDepth = 20
|
||||
|
||||
// Stack is a depth-limited LIFO queue of Referrals used to drive iterative
|
||||
// DNS traversal. Pushing a Referral whose Depth exceeds maxDepth fails
|
||||
// silently and returns false, preventing unbounded traversal.
|
||||
type Stack struct {
|
||||
items []*Referral
|
||||
maxDepth int
|
||||
}
|
||||
|
||||
// NewStack creates a Stack with the given maximum depth.
|
||||
// When maxDepth is ≤ 0, DefaultMaxDepth is used.
|
||||
func NewStack(maxDepth int) *Stack {
|
||||
if maxDepth <= 0 {
|
||||
maxDepth = DefaultMaxDepth
|
||||
@@ -17,6 +23,8 @@ func NewStack(maxDepth int) *Stack {
|
||||
}
|
||||
}
|
||||
|
||||
// Push adds r to the stack. Returns false (and does not add) when r is nil
|
||||
// or r.Depth >= maxDepth.
|
||||
func (s *Stack) Push(r *Referral) bool {
|
||||
if r == nil {
|
||||
return false
|
||||
@@ -28,6 +36,7 @@ func (s *Stack) Push(r *Referral) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// Pop removes and returns the top Referral, or nil when the stack is empty.
|
||||
func (s *Stack) Pop() *Referral {
|
||||
if len(s.items) == 0 {
|
||||
return nil
|
||||
@@ -38,6 +47,7 @@ func (s *Stack) Pop() *Referral {
|
||||
return item
|
||||
}
|
||||
|
||||
// Peek returns the top Referral without removing it, or nil when empty.
|
||||
func (s *Stack) Peek() *Referral {
|
||||
if len(s.items) == 0 {
|
||||
return nil
|
||||
@@ -45,14 +55,17 @@ func (s *Stack) Peek() *Referral {
|
||||
return s.items[len(s.items)-1]
|
||||
}
|
||||
|
||||
// Len returns the current number of items in the stack.
|
||||
func (s *Stack) Len() int {
|
||||
return len(s.items)
|
||||
}
|
||||
|
||||
// MaxDepth returns the configured maximum depth for this stack.
|
||||
func (s *Stack) MaxDepth() int {
|
||||
return s.maxDepth
|
||||
}
|
||||
|
||||
// IsEmpty reports whether the stack has no items.
|
||||
func (s *Stack) IsEmpty() bool {
|
||||
return len(s.items) == 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user