添加了多处错误与日志描述

This commit is contained in:
M09Ic 2023-01-12 16:35:34 +08:00
parent 427f64f57a
commit 02195a8005
4 changed files with 33 additions and 7 deletions

View File

@ -73,6 +73,8 @@ func Spray() {
logs.Log.Level = logs.Debug logs.Log.Level = logs.Debug
} }
logs.DefaultColorMap[logs.Info] = logs.PurpleBold
logs.DefaultColorMap[logs.Important] = logs.GreenBold
pkg.Distance = uint8(option.SimhashDistance) pkg.Distance = uint8(option.SimhashDistance)
ihttp.DefaultMaxBodySize = option.MaxBodyLength * 1024 ihttp.DefaultMaxBodySize = option.MaxBodyLength * 1024
internal.MaxCrawl = option.CrawlDepth internal.MaxCrawl = option.CrawlDepth

View File

@ -143,8 +143,6 @@ func (opt *Option) PrepareRunner() (*Runner, error) {
// log and bar // log and bar
if !opt.NoColor { if !opt.NoColor {
logs.Log.Color = true logs.Log.Color = true
logs.DefaultColorMap[logs.Info] = logs.PurpleBold
logs.DefaultColorMap[logs.Important] = logs.Green
r.Color = true r.Color = true
} }
if opt.Quiet { if opt.Quiet {
@ -182,6 +180,25 @@ func (opt *Option) PrepareRunner() (*Runner, error) {
} else if opt.FileBak { } else if opt.FileBak {
opt.AppendRule = append(opt.AppendRule, "filebak") opt.AppendRule = append(opt.AppendRule, "filebak")
} }
var s strings.Builder
if r.Crawl {
s.WriteString("crawl enable; ")
}
if r.Active {
s.WriteString("active fingerprint enable; ")
}
if r.Bak {
s.WriteString("bak file enable; ")
}
if r.Common {
s.WriteString("common file enable; ")
}
if len(opt.AppendRule) > 0 {
s.WriteString("file bak enable; ")
}
if s.Len() > 0 {
logs.Log.Important("Advance Mod: " + s.String())
}
if opt.BlackStatus != "" { if opt.BlackStatus != "" {
for _, s := range strings.Split(opt.BlackStatus, ",") { for _, s := range strings.Split(opt.BlackStatus, ",") {

View File

@ -184,6 +184,9 @@ func (pool *Pool) Init() error {
if pool.index.ErrString != "" { if pool.index.ErrString != "" {
return fmt.Errorf(pool.index.String()) return fmt.Errorf(pool.index.String())
} }
if pool.index.Chunked && pool.ClientType == ihttp.FAST {
logs.Log.Warn("chunk encoding! buf current client FASTHTTP not support chunk decode")
}
logs.Log.Info("[baseline.index] " + pool.index.Format([]string{"status", "length", "spend", "title", "frame", "redirect"})) logs.Log.Info("[baseline.index] " + pool.index.Format([]string{"status", "length", "spend", "title", "frame", "redirect"}))
// 检测基本访问能力 // 检测基本访问能力
if pool.random.ErrString != "" { if pool.random.ErrString != "" {

View File

@ -30,6 +30,7 @@ func NewBaseline(u, host string, resp *ihttp.Response) *Baseline {
copy(bl.Body, body) copy(bl.Body, body)
if i == -1 { if i == -1 {
bl.Chunked = true
bl.BodyLength = len(bl.Body) bl.BodyLength = len(bl.Body)
} else { } else {
bl.BodyLength = i bl.BodyLength = i
@ -45,12 +46,13 @@ func NewBaseline(u, host string, resp *ihttp.Response) *Baseline {
bl.Raw = append(bl.Header, bl.Body...) bl.Raw = append(bl.Header, bl.Body...)
bl.RedirectURL = resp.GetHeader("Location") bl.RedirectURL = resp.GetHeader("Location")
bl.Dir = bl.IsDir()
uu, err := url.Parse(u) uu, err := url.Parse(u)
if err == nil { if err == nil {
bl.Path = uu.Path bl.Path = uu.Path
bl.Url = uu bl.Url = uu
} }
bl.Dir = bl.IsDir()
if bl.Url.Host != host { if bl.Url.Host != host {
bl.Host = host bl.Host = host
} }
@ -70,13 +72,14 @@ func NewInvalidBaseline(u, host string, resp *ihttp.Response, reason string) *Ba
bl.BodyLength = resp.ContentLength() bl.BodyLength = resp.ContentLength()
bl.RedirectURL = string(resp.GetHeader("Location")) bl.RedirectURL = string(resp.GetHeader("Location"))
bl.Dir = bl.IsDir()
uu, err := url.Parse(u) uu, err := url.Parse(u)
if err == nil { if err == nil {
bl.Path = uu.Path bl.Path = uu.Path
bl.Url = uu bl.Url = uu
} else {
return bl return bl
} }
bl.Dir = bl.IsDir()
if bl.Url.Host != host { if bl.Url.Host != host {
bl.Host = host bl.Host = host
@ -90,7 +93,8 @@ type Baseline struct {
Url *url.URL `json:"-"` Url *url.URL `json:"-"`
UrlString string `json:"url"` UrlString string `json:"url"`
Path string `json:"path"` Path string `json:"path"`
Dir bool `json:"isdir"` Dir bool `json:"-"`
Chunked bool `json:"-"`
Host string `json:"host"` Host string `json:"host"`
Body []byte `json:"-"` Body []byte `json:"-"`
BodyLength int `json:"body_length"` BodyLength int `json:"body_length"`
@ -361,7 +365,7 @@ func (bl *Baseline) ColorString() string {
} }
if len(bl.Extracteds) > 0 { if len(bl.Extracteds) > 0 {
for _, e := range bl.Extracteds { for _, e := range bl.Extracteds {
line.WriteString("\n " + e.Name + ": \n\t") line.WriteString("\n " + e.Name + " (" + strconv.Itoa(len(e.ExtractResult)) + ") items : \n\t")
line.WriteString(logs.GreenLine(strings.Join(e.ExtractResult, "\n\t"))) line.WriteString(logs.GreenLine(strings.Join(e.ExtractResult, "\n\t")))
} }
} }
@ -414,7 +418,7 @@ func (bl *Baseline) String() string {
} }
if len(bl.Extracteds) > 0 { if len(bl.Extracteds) > 0 {
for _, e := range bl.Extracteds { for _, e := range bl.Extracteds {
line.WriteString("\n " + e.Name + ": \n\t") line.WriteString("\n " + e.Name + " (" + strconv.Itoa(len(e.ExtractResult)) + ") items : \n\t")
line.WriteString(strings.Join(e.ExtractResult, "\n\t")) line.WriteString(strings.Join(e.ExtractResult, "\n\t"))
} }
} }