You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 3e0ed5b
Browse filesBrowse the repository at this point in the historyBrowse files
Embed scan.Config in scan.Options instead of copying it (#331)
scan.Options and scan.Config declared the same settings, and
Options.Config() copied about 25 fields one by one, so every engine
option took three edits in internal/scan before a front end saw it. The
only differences were the timeout's unit (TimeoutMs against a Duration)
and the two settings that are checked but not passed on.
Options now embeds Config and keeps only MaxDuration and RatePerResolver
beside it; the copy and TestOptionsConfig are gone, and the front ends
pass opts.Config to scan.Run. The timeout is a Duration everywhere: the
CLI and the TUI convert their milliseconds, the library keeps rounding
up to whole milliseconds, and Validate keeps its "at least 1 ms"
message.
The three front-end drift tests now walk the new Options.Fields(), the
embedded Config's exported fields and Options' own, so they still check
every setting; walking Options' top-level fields alone would have seen
one non-zero Config and passed whatever was left unset. Resolver, which
scan.Run builds from DNSServer, is listed as unmapped in each.
Fixes#331
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
internal/scan/autorate.go - autoRate: the -auto-rate back-off controller
@@ -183,7 +183,7 @@ tools/licenses/main.go - THIRD_PARTY_LICENSES for release archives and t
183
183
184
184
***Purpose**: To efficiently perform DNS lookups for a large number of potential subdomains, `subenum` employs a worker pool pattern. This allows multiple DNS queries to be in flight concurrently, significantly speeding up the enumeration process compared to sequential lookups.
185
185
***Implementation**: The scan engine lives in `internal/scan/runner.go` as `scan.Run`, which takes a context, a `scan.Config`, and an events channel. Both the CLI (`scanTarget` in `internal/cli/cli.go`) and the TUI call it.
186
-
***`scan.Options` / `scan.Config`**: `Options` holds the user-facing settings (timeout in milliseconds, attempts, rate, and so on). Its `Validate` method checks ranges and the resolver address, and its `Config`method builds the`scan.Config` the engine runs on. The CLI, the TUI and `pkg/subenum` each fill in an `Options`, so they cannot drift apart in what they accept, and each has a test that fails when an `Options` field is left unset without a listed reason. `scan.DefaultConcurrency`, `DefaultTimeoutMs` and `DefaultHitRate` are the defaults all three use.
186
+
***`scan.Options` / `scan.Config`**: `Options` holds the user-facing settings: it embeds the `scan.Config` the engine runs on, plus `MaxDuration`and `RatePerResolver`, which are only checked there (#331). Its `Validate` method checks ranges and the resolver address, and its `Config`field is what`scan.Run` takes. The CLI, the TUI and `pkg/subenum` each fill in an `Options`, so they cannot drift apart in what they accept, and each has a test that walks `Options.Fields()` and fails when a setting is left unset without a listed reason. `scan.DefaultConcurrency`, `DefaultTimeoutMs` and `DefaultHitRate` are the defaults all three use.
187
187
***`scan.Event` / `scan.EventKind`**: Typed events emitted on the channel: `EventResult` (a `scan.Result`: subdomain, records, simulated flag, takeover hint and internal address scope), `EventProgress`, `EventNotice`, `EventError`, and `EventDone`. An `EventNotice` carries a `scan.NoticeKind` (`NoticeWildcard`, `NoticeCap`, `NoticeCeiling`, `NoticeSkip`, `NoticeRate`) so consumers can style or filter notices without parsing the message. `EventDone` carries a `scan.Stats` snapshot with per-outcome counters (found, nxdomain, timeout, refused, other, wildcard-filtered).
188
188
***Preflight and wildcard check**: Before any candidate is dispatched, `scan.Run` resolves the apex (with retries) and runs `Lookup.FingerprintWildcard`; see the Data Flow section.
189
189
* **Dispatcher and lazy candidate generation**: A dispatcher goroutine owns the internal `jobs` channel, which carries chunks of jobs rather than single jobs: `nextChunk` hands each send up to one worker's share of what is left, at most `maxChunk` (8), so a large scan pays one channel operation per chunk and the tail still spreads over every worker. `jobs` and `completed` are buffered (`handoffPerWorker` = 4 sends per worker), so workers and the dispatcher rarely wait on each other. The dispatcher also keeps a queue of *expansions* (a parent name plus a cursor into `Config.Entries`), the set of parents already queued (recursive scans only), and a pending-work counter. A set of generated candidates is kept only for a recursive scan whose entries include a multi-label one, the only case where two parents can reach the same name. Candidate names are built only as they are dispatched, so a found parent costs one queue entry rather than one per wordlist entry, and the queue is compacted as it is consumed. `-max-queries` stops admission once the cap is reached; the remaining candidates are counted, never built, and reported in a `NoticeCap` notice.
0 commit comments