mirror of
https://github.com/chainreactors/spray.git
synced 2025-09-15 11:40:13 +00:00
enhance probe output
This commit is contained in:
parent
e483bb4439
commit
af82ae43b9
@ -39,18 +39,21 @@ func Format(opts Option) {
|
|||||||
group[result.Url.Host] = append(group[result.Url.Host], &result)
|
group[result.Url.Host] = append(group[result.Url.Host], &result)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 分组
|
|
||||||
|
|
||||||
for _, results := range group {
|
for _, results := range group {
|
||||||
for _, result := range results {
|
for _, result := range results {
|
||||||
if !opts.Fuzzy && result.IsFuzzy {
|
if !opts.Fuzzy && result.IsFuzzy {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if opts.OutputProbe == "" {
|
||||||
if !opts.NoColor {
|
if !opts.NoColor {
|
||||||
logs.Log.Console(result.ColorString() + "\n")
|
logs.Log.Console(result.ColorString() + "\n")
|
||||||
} else {
|
} else {
|
||||||
logs.Log.Console(result.String() + "\n")
|
logs.Log.Console(result.String() + "\n")
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
probes := strings.Split(opts.OutputProbe, ",")
|
||||||
|
logs.Log.Console(result.ProbeOutput(probes) + "\n")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -364,7 +364,7 @@ func (r *Runner) Output(bl *pkg.Baseline) {
|
|||||||
if r.Option.Json {
|
if r.Option.Json {
|
||||||
out = bl.ToJson()
|
out = bl.ToJson()
|
||||||
} else if len(r.Probes) > 0 {
|
} else if len(r.Probes) > 0 {
|
||||||
out = bl.Format(r.Probes)
|
out = bl.ProbeOutput(r.Probes)
|
||||||
} else if r.Color {
|
} else if r.Color {
|
||||||
out = bl.ColorString()
|
out = bl.ColorString()
|
||||||
} else {
|
} else {
|
||||||
@ -385,7 +385,7 @@ func (r *Runner) Output(bl *pkg.Baseline) {
|
|||||||
} else if r.FileOutput == "full" {
|
} else if r.FileOutput == "full" {
|
||||||
r.OutputFile.SafeWrite(bl.String() + "\n")
|
r.OutputFile.SafeWrite(bl.String() + "\n")
|
||||||
} else {
|
} else {
|
||||||
r.OutputFile.SafeWrite(bl.Format(strings.Split(r.FileOutput, ",")) + "\n")
|
r.OutputFile.SafeWrite(bl.ProbeOutput(strings.Split(r.FileOutput, ",")) + "\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
r.OutputFile.SafeSync()
|
r.OutputFile.SafeSync()
|
||||||
|
@ -235,6 +235,15 @@ func (bl *Baseline) Compare(other *Baseline) int {
|
|||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (bl *Baseline) ProbeOutput(format []string) string {
|
||||||
|
var s strings.Builder
|
||||||
|
for _, f := range format {
|
||||||
|
s.WriteString("\t")
|
||||||
|
s.WriteString(bl.Get(f))
|
||||||
|
}
|
||||||
|
return strings.TrimSpace(s.String())
|
||||||
|
}
|
||||||
|
|
||||||
var Distance uint8 = 5 // 数字越小越相似, 数字为0则为完全一致.
|
var Distance uint8 = 5 // 数字越小越相似, 数字为0则为完全一致.
|
||||||
|
|
||||||
func (bl *Baseline) FuzzyCompare(other *Baseline) bool {
|
func (bl *Baseline) FuzzyCompare(other *Baseline) bool {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user