MCPcopy Create free account
hub / github.com/chainreactors/spray / Prepare

Method Prepare

core/option.go:440–510  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

438}
439
440func (opt *Option) Prepare() error {
441 var err error
442 logs.Log.SetColor(true)
443
444 // Validate finger engines
445 if err = opt.ValidateFingerEngines(); err != nil {
446 return err
447 }
448
449 err = opt.Validate()
450 if err != nil {
451 return err
452 }
453
454 // Load dynamic fingerprints from custom files/URLs
455 err = opt.LoadDynamicFingers()
456 if err != nil {
457 return err
458 }
459
460 err = pkg.Load()
461 if err != nil {
462 return err
463 }
464
465 if opt.ExtractContext > 0 {
466 pkg.ExtractContextSize = opt.ExtractContext
467 }
468
469 if opt.Extracts != nil {
470 var knownNames []string
471 for _, e := range opt.Extracts {
472 if _, ok := pkg.ExtractRegexps[e]; ok {
473 knownNames = append(knownNames, e)
474 } else if pkg.IsProtonExtractor(e) {
475 knownNames = append(knownNames, e)
476 } else {
477 pkg.AddCustomExtractor(e, e)
478 knownNames = append(knownNames, e)
479 }
480 }
481 pkg.EnableExtractors(knownNames)
482 }
483 if opt.ExtractConfig != "" {
484 pkg.LoadProtonTemplatesFromDir(opt.ExtractConfig)
485 }
486
487 // 初始化全局变量
488 baseline.Distance = uint8(opt.SimhashDistance)
489 if opt.MaxBodyLength == -1 {
490 ihttp.DefaultMaxBodySize = -1
491 } else {
492 ihttp.DefaultMaxBodySize = opt.MaxBodyLength * 1024
493 }
494
495 pkg.BlackStatus = pkg.ParseStatus(pkg.DefaultBlackStatus, opt.BlackStatus)
496 pkg.WhiteStatus = pkg.ParseStatus(pkg.DefaultWhiteStatus, opt.WhiteStatus)
497 if opt.FuzzyStatus == "all" {

Callers 1

RunWithArgsFunction · 0.95

Calls 9

ValidateFingerEnginesMethod · 0.95
ValidateMethod · 0.95
LoadDynamicFingersMethod · 0.95
LoadFunction · 0.92
IsProtonExtractorFunction · 0.92
AddCustomExtractorFunction · 0.92
EnableExtractorsFunction · 0.92
ParseStatusFunction · 0.92

Tested by

no test coverage detected