diff --git a/plugin/plaintext/text_in.go b/plugin/plaintext/text_in.go index 631be4dac..78d2a9224 100644 --- a/plugin/plaintext/text_in.go +++ b/plugin/plaintext/text_in.go @@ -33,6 +33,7 @@ func newTextIn(action lib.Action, data json.RawMessage) (lib.InputConverter, err Name string `json:"name"` URI string `json:"uri"` InputDir string `json:"inputDir"` + Want []string `json:"wantedList"` OnlyIPType lib.IPType `json:"onlyIPType"` } @@ -50,6 +51,14 @@ func newTextIn(action lib.Action, data json.RawMessage) (lib.InputConverter, err return nil, fmt.Errorf("type %s | action %s name & uri must be specified together", typeTextIn, action) } + // Filter want list + wantList := make(map[string]bool) + for _, want := range tmp.Want { + if want = strings.ToUpper(strings.TrimSpace(want)); want != "" { + wantList[want] = true + } + } + return &textIn{ Type: typeTextIn, Action: action, @@ -57,6 +66,7 @@ func newTextIn(action lib.Action, data json.RawMessage) (lib.InputConverter, err Name: tmp.Name, URI: tmp.URI, InputDir: tmp.InputDir, + Want: wantList, OnlyIPType: tmp.OnlyIPType, }, nil } @@ -68,6 +78,7 @@ type textIn struct { Name string URI string InputDir string + Want map[string]bool OnlyIPType lib.IPType } @@ -175,6 +186,10 @@ func (t *textIn) walkLocalFile(path, name string, entries map[string]*lib.Entry) } entryName = strings.ToUpper(entryName) + + if len(t.Want) > 0 && !t.Want[entryName] { + return nil + } if _, found := entries[entryName]; found { return fmt.Errorf("found duplicated list %s", entryName) } @@ -206,6 +221,11 @@ func (t *textIn) walkRemoteFile(url, name string, entries map[string]*lib.Entry) } name = strings.ToUpper(name) + + if len(t.Want) > 0 && !t.Want[name] { + return nil + } + entry := lib.NewEntry(name) if err := t.scanFile(resp.Body, entry); err != nil { return err