From 2a9ca15b9cdd28061520887a798ad06ddd6566ed Mon Sep 17 00:00:00 2001 From: M09Ic Date: Thu, 10 Nov 2022 21:26:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E--distance=E5=8F=82=E6=95=B0,?= =?UTF-8?q?=20=E6=8E=A7=E5=88=B6simhash=E9=98=88=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/option.go | 13 +++++++++---- pkg/baseline.go | 4 +++- 2 files changed, 12 insertions(+), 5 deletions(-) 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