Skip to content

Commit

Permalink
-j参数支持--filter
Browse files Browse the repository at this point in the history
  • Loading branch information
M09Ic committed Nov 2, 2022
1 parent 4b77a6f commit 4521364
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion v2/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/chainreactors/files v0.2.3
github.com/chainreactors/ipcs v0.0.9
github.com/chainreactors/logs v0.6.1
github.com/chainreactors/parsers v0.1.7
github.com/chainreactors/parsers v0.1.8
github.com/jessevdk/go-flags v1.5.0
github.com/panjf2000/ants/v2 v2.5.0
golang.org/x/net v0.0.0-20190603091049-60506f45cf65
Expand Down
4 changes: 2 additions & 2 deletions v2/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ github.com/chainreactors/ipcs v0.0.9 h1:4Onroq7gXLG5SLCCgNDx3JmtLxB4XgepGdHCtLp1
github.com/chainreactors/ipcs v0.0.9/go.mod h1:E9M3Ohyq0TYQLlV4i2dbM9ThBZB1Nnd7Oexoie2xLII=
github.com/chainreactors/logs v0.6.1 h1:+wLVqxErUyWYayAx6x+m5LA6jQBiHcLdTAJtiOUMoZU=
github.com/chainreactors/logs v0.6.1/go.mod h1:Y0EtAnoF0kiASIJUnXN0pcOt420iRpHOAnOhEphzRHA=
github.com/chainreactors/parsers v0.1.7 h1:zUDKEkYddTuijJTXI4hVJrnnPzqnUNd7ASw9pkGCNf0=
github.com/chainreactors/parsers v0.1.7/go.mod h1:Z9weht+lnFCk7UcwqFu6lXpS7u5vttiy0AJYOAyCCLA=
github.com/chainreactors/parsers v0.1.8 h1:i2ULyhthD4yYNWlef+82mNvRHz5zboJdt6qHsEs+nA4=
github.com/chainreactors/parsers v0.1.8/go.mod h1:Z9weht+lnFCk7UcwqFu6lXpS7u5vttiy0AJYOAyCCLA=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down
5 changes: 5 additions & 0 deletions v2/internal/core/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ func InitConfig(config *Config) (*Config, error) {
}
}

if config.Results != nil {
for _, filter := range config.Filters {
config.Results = config.Results.FilterWithString(filter)
}
}
err = config.InitIP()
if err != nil {
return nil, err
Expand Down
1 change: 1 addition & 0 deletions v2/internal/core/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ func (r *Runner) PrepareConfig() {
FilePath: r.FilePath,
Compress: r.Compress,
Tee: r.Tee,
Filters: r.Filters,
}

if r.FileOutputf == Default {
Expand Down
7 changes: 3 additions & 4 deletions v2/pkg/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@ type Config struct {
// file
IsListInput bool `json:"-"` // 从标准输入中读
IsJsonInput bool `json:"-"` // 从标准输入中读

NoSpray bool `json:"-"`

Compress bool `json:"-"`
NoSpray bool `json:"-"`
Compress bool `json:"-"`

// output
FilePath string `json:"-"`
Expand All @@ -57,6 +55,7 @@ type Config struct {
Filenamef string `json:"-"`
Results parsers.GOGOResults `json:"-"` // json反序列化后的内网,保存在内存中
HostsMap map[string][]string `json:"-"` // host映射表
Filters []string `json:"-"`
}

func (config *Config) InitIP() error {
Expand Down

0 comments on commit 4521364

Please sign in to comment.