fix: address code review issues on PR #10 (HAN-384)

- runner.go: store fingerprints in local var, call formatter.SetFingerprints()
  instead of mutating caller's *Config; removes Fingerprints field from Config
- fingerprint.go: use singleflight.Group in Query to coalesce concurrent
  probes for the same IP, eliminating the double-probe race
- output layer: add SetFingerprints(map[string]string) to Formatter interface;
  textFormatter and jsonFormatter each hold their own fingerprints field
- formatter_test.go: add TestTextFormatterWriteSummaryShowsVersions and
  TestJSONFormatterWriteSummaryShowsVersions verifying version output

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 02:59:38 +10:00
co-authored by Copilot multica-agent
parent 3e7580b919
commit c96d18859f
7 changed files with 113 additions and 20 deletions
+3 -3
View File
@@ -31,9 +31,6 @@ type Config struct {
Color bool
Debug int
// Fingerprints maps server IP strings to their version.bind version strings.
// Populated by RunTraversal when ShowVersions and ShowServers are both true.
Fingerprints map[string]string
}
func DefaultConfig() *Config {
@@ -56,6 +53,9 @@ type Formatter interface {
WriteResult(result traverse.TraversalResult) error
WriteSummary(results []traverse.TraversalResult) error
Flush() error
// SetFingerprints supplies server-version data to the formatter.
// Call before WriteSummary when ShowVersions is true.
SetFingerprints(fps map[string]string)
}
func NewFormatter(cfg *Config, w io.Writer) Formatter {