diff --git a/internal/option.go b/internal/option.go index af7e919..a85d25d 100644 --- a/internal/option.go +++ b/internal/option.go @@ -47,10 +47,11 @@ type OutputOptions struct { } type RequestOptions struct { - Headers []string `long:"header"` - Method string `long:"method"` - Cookie string `long:"cookie"` - Force bool `long:"force"` + Headers []string `long:"header"` + Method string `long:"method"` + Cookie string `long:"cookie"` + Force bool `long:"force"` + SimhashDistance int `long:"distance"` } type MiscOptions struct { @@ -99,6 +100,10 @@ func (opt *Option) PrepareRunner() (*Runner, error) { logs.Log.Writer = r.Progress.Bypass() } + if opt.SimhashDistance != 0 { + pkg.Distance = uint8(opt.SimhashDistance) + } + if opt.Force { breakThreshold = 999999 } diff --git a/pkg/baseline.go b/pkg/baseline.go index 7c674c1..598df69 100644 --- a/pkg/baseline.go +++ b/pkg/baseline.go @@ -116,9 +116,11 @@ func (bl *Baseline) Compare(other *Baseline) int { return -1 } +var Distance uint8 + func (bl *Baseline) FuzzyCompare(other *Baseline) bool { // todo 模糊匹配 - if parsers.SimhashCompare(other.BodySimhash, bl.BodySimhash) < 3 { + if parsers.SimhashCompare(other.BodySimhash, bl.BodySimhash) < Distance { return true } return false