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:
co-authored by
Copilot
multica-agent
parent
3e7580b919
commit
c96d18859f
@@ -11,14 +11,19 @@ import (
|
||||
)
|
||||
|
||||
type textFormatter struct {
|
||||
cfg *Config
|
||||
w io.Writer
|
||||
cfg *Config
|
||||
w io.Writer
|
||||
fingerprints map[string]string
|
||||
}
|
||||
|
||||
func newTextFormatter(cfg *Config, w io.Writer) *textFormatter {
|
||||
return &textFormatter{cfg: cfg, w: w}
|
||||
}
|
||||
|
||||
func (f *textFormatter) SetFingerprints(fps map[string]string) {
|
||||
f.fingerprints = fps
|
||||
}
|
||||
|
||||
func (f *textFormatter) WriteProgress(event traverse.TraversalEvent) error {
|
||||
if event.Stage != traverse.EventStart {
|
||||
return nil
|
||||
@@ -101,7 +106,7 @@ func (f *textFormatter) writeServers(results []traverse.TraversalResult) error {
|
||||
for _, ip := range servers[name] {
|
||||
line := fmt.Sprintf("%*s: %-15s", width, name, ip)
|
||||
if f.cfg.ShowVersions {
|
||||
if version, ok := f.cfg.Fingerprints[ip]; ok && version != "" {
|
||||
if version, ok := f.fingerprints[ip]; ok && version != "" {
|
||||
line += " " + version
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user