diff options
| author | copilot-swe-agent[bot] <[email protected]> | 2026-03-09 06:35:47 +0000 |
|---|---|---|
| committer | copilot-swe-agent[bot] <[email protected]> | 2026-03-09 06:35:47 +0000 |
| commit | 2600825c50d7e7f2b4427674f1aefca270bcca27 (patch) | |
| tree | 18f216c6af28fd3975a0665d75ccf7b5c0078cb6 /plugin/plaintext | |
| parent | 5a14eb90f575b983aa407341af91aa7654e65f12 (diff) | |
Refactor: all plugin subdirectories use option patterncopilot/modify-plugin-files-subdirectories
Apply the same functional options pattern from plugin/singbox to:
- plugin/mihomo (mrs_in.go, mrs_out.go)
- plugin/plaintext (text_in.go, common_in.go, common_out.go, text_out.go, clash_in.go, clash_out.go, json_in.go, surge_in.go, surge_out.go)
- plugin/maxmind (all input/output files)
- plugin/v2ray (dat_in.go, dat_out.go)
- plugin/special (cutter.go, lookup.go, private.go, stdin.go, stdout.go)
- lookup.go and merge.go updated to use new constructors
Co-authored-by: Loyalsoldier <[email protected]>
Diffstat (limited to 'plugin/plaintext')
| -rw-r--r-- | plugin/plaintext/clash_in.go | 8 | ||||
| -rw-r--r-- | plugin/plaintext/clash_out.go | 8 | ||||
| -rw-r--r-- | plugin/plaintext/common_in.go | 18 | ||||
| -rw-r--r-- | plugin/plaintext/common_out.go | 134 | ||||
| -rw-r--r-- | plugin/plaintext/json_in.go | 4 | ||||
| -rw-r--r-- | plugin/plaintext/surge_in.go | 4 | ||||
| -rw-r--r-- | plugin/plaintext/surge_out.go | 4 | ||||
| -rw-r--r-- | plugin/plaintext/text_in.go | 128 | ||||
| -rw-r--r-- | plugin/plaintext/text_out.go | 14 |
9 files changed, 220 insertions, 102 deletions
diff --git a/plugin/plaintext/clash_in.go b/plugin/plaintext/clash_in.go index be77cc62..a714b20d 100644 --- a/plugin/plaintext/clash_in.go +++ b/plugin/plaintext/clash_in.go @@ -21,16 +21,16 @@ const ( func init() { lib.RegisterInputConfigCreator(TypeClashRuleSetClassicalIn, func(action lib.Action, data json.RawMessage) (lib.InputConverter, error) { - return newTextIn(TypeClashRuleSetClassicalIn, DescClashRuleSetClassicalIn, action, data) + return NewTextInFromBytes(TypeClashRuleSetClassicalIn, DescClashRuleSetClassicalIn, action, data) }) - lib.RegisterInputConverter(TypeClashRuleSetClassicalIn, &TextIn{ + lib.RegisterInputConverter(TypeClashRuleSetClassicalIn, &text_in{ Description: DescClashRuleSetClassicalIn, }) lib.RegisterInputConfigCreator(TypeClashRuleSetIPCIDRIn, func(action lib.Action, data json.RawMessage) (lib.InputConverter, error) { - return newTextIn(TypeClashRuleSetIPCIDRIn, DescClashRuleSetIPCIDRIn, action, data) + return NewTextInFromBytes(TypeClashRuleSetIPCIDRIn, DescClashRuleSetIPCIDRIn, action, data) }) - lib.RegisterInputConverter(TypeClashRuleSetIPCIDRIn, &TextIn{ + lib.RegisterInputConverter(TypeClashRuleSetIPCIDRIn, &text_in{ Description: DescClashRuleSetIPCIDRIn, }) } diff --git a/plugin/plaintext/clash_out.go b/plugin/plaintext/clash_out.go index e7a97f1b..9e7644d6 100644 --- a/plugin/plaintext/clash_out.go +++ b/plugin/plaintext/clash_out.go @@ -21,16 +21,16 @@ const ( func init() { lib.RegisterOutputConfigCreator(TypeClashRuleSetClassicalOut, func(action lib.Action, data json.RawMessage) (lib.OutputConverter, error) { - return newTextOut(TypeClashRuleSetClassicalOut, DescClashRuleSetClassicalOut, action, data) + return NewTextOutFromBytes(TypeClashRuleSetClassicalOut, DescClashRuleSetClassicalOut, action, data) }) - lib.RegisterOutputConverter(TypeClashRuleSetClassicalOut, &TextOut{ + lib.RegisterOutputConverter(TypeClashRuleSetClassicalOut, &text_out{ Description: DescClashRuleSetClassicalOut, }) lib.RegisterOutputConfigCreator(TypeClashRuleSetIPCIDROut, func(action lib.Action, data json.RawMessage) (lib.OutputConverter, error) { - return newTextOut(TypeClashRuleSetIPCIDROut, DescClashRuleSetIPCIDROut, action, data) + return NewTextOutFromBytes(TypeClashRuleSetIPCIDROut, DescClashRuleSetIPCIDROut, action, data) }) - lib.RegisterOutputConverter(TypeClashRuleSetIPCIDROut, &TextOut{ + lib.RegisterOutputConverter(TypeClashRuleSetIPCIDROut, &text_out{ Description: DescClashRuleSetIPCIDROut, }) } diff --git a/plugin/plaintext/common_in.go b/plugin/plaintext/common_in.go index f8253519..44f7168f 100644 --- a/plugin/plaintext/common_in.go +++ b/plugin/plaintext/common_in.go @@ -11,7 +11,7 @@ import ( "gopkg.in/yaml.v2" ) -type TextIn struct { +type text_in struct { Type string Action lib.Action Description string @@ -27,7 +27,7 @@ type TextIn struct { RemoveSuffixesInLine []string } -func (t *TextIn) scanFile(reader io.Reader, entry *lib.Entry) error { +func (t *text_in) scanFile(reader io.Reader, entry *lib.Entry) error { var err error switch t.Type { case TypeTextIn: @@ -47,7 +47,7 @@ func (t *TextIn) scanFile(reader io.Reader, entry *lib.Entry) error { return err } -func (t *TextIn) scanFileForTextIn(reader io.Reader, entry *lib.Entry) error { +func (t *text_in) scanFileForTextIn(reader io.Reader, entry *lib.Entry) error { scanner := bufio.NewScanner(reader) for scanner.Scan() { line := scanner.Text() @@ -83,7 +83,7 @@ func (t *TextIn) scanFileForTextIn(reader io.Reader, entry *lib.Entry) error { return nil } -func (t *TextIn) readClashRuleSetYAMLFile(reader io.Reader) ([]string, error) { +func (t *text_in) readClashRuleSetYAMLFile(reader io.Reader) ([]string, error) { var payload struct { Payload []string `yaml:"payload"` } @@ -100,7 +100,7 @@ func (t *TextIn) readClashRuleSetYAMLFile(reader io.Reader) ([]string, error) { return payload.Payload, nil } -func (t *TextIn) scanFileForClashIPCIDRRuleSetIn(reader io.Reader, entry *lib.Entry) error { +func (t *text_in) scanFileForClashIPCIDRRuleSetIn(reader io.Reader, entry *lib.Entry) error { payload, err := t.readClashRuleSetYAMLFile(reader) if err != nil { return err @@ -119,7 +119,7 @@ func (t *TextIn) scanFileForClashIPCIDRRuleSetIn(reader io.Reader, entry *lib.En return nil } -func (t *TextIn) scanFileForClashClassicalRuleSetIn(reader io.Reader, entry *lib.Entry) error { +func (t *text_in) scanFileForClashClassicalRuleSetIn(reader io.Reader, entry *lib.Entry) error { payload, err := t.readClashRuleSetYAMLFile(reader) if err != nil { return err @@ -154,7 +154,7 @@ func (t *TextIn) scanFileForClashClassicalRuleSetIn(reader io.Reader, entry *lib return nil } -func (t *TextIn) scanFileForSurgeRuleSetIn(reader io.Reader, entry *lib.Entry) error { +func (t *text_in) scanFileForSurgeRuleSetIn(reader io.Reader, entry *lib.Entry) error { scanner := bufio.NewScanner(reader) for scanner.Scan() { line := scanner.Text() @@ -193,7 +193,7 @@ func (t *TextIn) scanFileForSurgeRuleSetIn(reader io.Reader, entry *lib.Entry) e return nil } -func (t *TextIn) scanFileForJSONIn(reader io.Reader, entry *lib.Entry) error { +func (t *text_in) scanFileForJSONIn(reader io.Reader, entry *lib.Entry) error { data, err := io.ReadAll(reader) if err != nil { return err @@ -217,7 +217,7 @@ func (t *TextIn) scanFileForJSONIn(reader io.Reader, entry *lib.Entry) error { return nil } -func (t *TextIn) processJSONResult(result gjson.Result, entry *lib.Entry) error { +func (t *text_in) processJSONResult(result gjson.Result, entry *lib.Entry) error { switch { case !result.Exists(): return fmt.Errorf("invaild IP address or CIDR (value not exist), please check your specified JSON path or JSON source") diff --git a/plugin/plaintext/common_out.go b/plugin/plaintext/common_out.go index cc7ba41e..e508fa9d 100644 --- a/plugin/plaintext/common_out.go +++ b/plugin/plaintext/common_out.go @@ -7,6 +7,7 @@ import ( "net" "os" "path/filepath" + "strings" "github.com/Loyalsoldier/geoip/lib" ) @@ -18,7 +19,7 @@ var ( defaultOutputDirForSurgeRuleSetOut = filepath.Join("./", "output", "surge") ) -type TextOut struct { +type text_out struct { Type string Action lib.Action Description string @@ -32,7 +33,84 @@ type TextOut struct { AddSuffixInLine string } -func newTextOut(iType string, iDesc string, action lib.Action, data json.RawMessage) (lib.OutputConverter, error) { +func NewTextOut(iType string, iDesc string, action lib.Action, opts ...lib.OutputOption) lib.OutputConverter { + t := &text_out{ + Type: iType, + Action: action, + Description: iDesc, + } + + for _, opt := range opts { + if opt != nil { + opt(t) + } + } + + return t +} + +func WithOutputDir(dir string, iType string) lib.OutputOption { + return func(t lib.OutputConverter) { + dir = strings.TrimSpace(dir) + if dir == "" { + switch iType { + case TypeTextOut: + dir = defaultOutputDirForTextOut + case TypeClashRuleSetClassicalOut: + dir = defaultOutputDirForClashRuleSetClassicalOut + case TypeClashRuleSetIPCIDROut: + dir = defaultOutputDirForClashRuleSetIPCIDROut + case TypeSurgeRuleSetOut: + dir = defaultOutputDirForSurgeRuleSetOut + } + } + + t.(*text_out).OutputDir = dir + } +} + +func WithOutputExtension(ext string) lib.OutputOption { + return func(t lib.OutputConverter) { + ext = strings.TrimSpace(ext) + if ext == "" { + ext = ".txt" + } + + t.(*text_out).OutputExt = ext + } +} + +func WithOutputWantedList(lists []string) lib.OutputOption { + return func(t lib.OutputConverter) { + t.(*text_out).Want = lists + } +} + +func WithOutputExcludedList(lists []string) lib.OutputOption { + return func(t lib.OutputConverter) { + t.(*text_out).Exclude = lists + } +} + +func WithOutputOnlyIPType(onlyIPType lib.IPType) lib.OutputOption { + return func(t lib.OutputConverter) { + t.(*text_out).OnlyIPType = onlyIPType + } +} + +func WithAddPrefixInLine(prefix string) lib.OutputOption { + return func(t lib.OutputConverter) { + t.(*text_out).AddPrefixInLine = prefix + } +} + +func WithAddSuffixInLine(suffix string) lib.OutputOption { + return func(t lib.OutputConverter) { + t.(*text_out).AddSuffixInLine = suffix + } +} + +func NewTextOutFromBytes(iType string, iDesc string, action lib.Action, data []byte) (lib.OutputConverter, error) { var tmp struct { OutputDir string `json:"outputDir"` OutputExt string `json:"outputExtension"` @@ -50,39 +128,19 @@ func newTextOut(iType string, iDesc string, action lib.Action, data json.RawMess } } - if tmp.OutputDir == "" { - switch iType { - case TypeTextOut: - tmp.OutputDir = defaultOutputDirForTextOut - case TypeClashRuleSetClassicalOut: - tmp.OutputDir = defaultOutputDirForClashRuleSetClassicalOut - case TypeClashRuleSetIPCIDROut: - tmp.OutputDir = defaultOutputDirForClashRuleSetIPCIDROut - case TypeSurgeRuleSetOut: - tmp.OutputDir = defaultOutputDirForSurgeRuleSetOut - } - } - - if tmp.OutputExt == "" { - tmp.OutputExt = ".txt" - } - - return &TextOut{ - Type: iType, - Action: action, - Description: iDesc, - OutputDir: tmp.OutputDir, - OutputExt: tmp.OutputExt, - Want: tmp.Want, - Exclude: tmp.Exclude, - OnlyIPType: tmp.OnlyIPType, - - AddPrefixInLine: tmp.AddPrefixInLine, - AddSuffixInLine: tmp.AddSuffixInLine, - }, nil + return NewTextOut( + iType, iDesc, action, + WithOutputDir(tmp.OutputDir, iType), + WithOutputExtension(tmp.OutputExt), + WithOutputWantedList(tmp.Want), + WithOutputExcludedList(tmp.Exclude), + WithOutputOnlyIPType(tmp.OnlyIPType), + WithAddPrefixInLine(tmp.AddPrefixInLine), + WithAddSuffixInLine(tmp.AddSuffixInLine), + ), nil } -func (t *TextOut) marshalBytes(entry *lib.Entry) ([]byte, error) { +func (t *text_out) marshalBytes(entry *lib.Entry) ([]byte, error) { entryCidr, err := entry.MarshalText(lib.GetIgnoreIPType(t.OnlyIPType)) if err != nil { return nil, err @@ -108,7 +166,7 @@ func (t *TextOut) marshalBytes(entry *lib.Entry) ([]byte, error) { return buf.Bytes(), nil } -func (t *TextOut) marshalBytesForTextOut(buf *bytes.Buffer, entryCidr []string) error { +func (t *text_out) marshalBytesForTextOut(buf *bytes.Buffer, entryCidr []string) error { for _, cidr := range entryCidr { if t.AddPrefixInLine != "" { buf.WriteString(t.AddPrefixInLine) @@ -122,7 +180,7 @@ func (t *TextOut) marshalBytesForTextOut(buf *bytes.Buffer, entryCidr []string) return nil } -func (t *TextOut) marshalBytesForClashRuleSetClassicalOut(buf *bytes.Buffer, entryCidr []string) error { +func (t *text_out) marshalBytesForClashRuleSetClassicalOut(buf *bytes.Buffer, entryCidr []string) error { buf.WriteString("payload:\n") for _, cidr := range entryCidr { ip, _, err := net.ParseCIDR(cidr) @@ -141,7 +199,7 @@ func (t *TextOut) marshalBytesForClashRuleSetClassicalOut(buf *bytes.Buffer, ent return nil } -func (t *TextOut) marshalBytesForClashRuleSetIPCIDROut(buf *bytes.Buffer, entryCidr []string) error { +func (t *text_out) marshalBytesForClashRuleSetIPCIDROut(buf *bytes.Buffer, entryCidr []string) error { buf.WriteString("payload:\n") for _, cidr := range entryCidr { buf.WriteString(" - '") @@ -152,7 +210,7 @@ func (t *TextOut) marshalBytesForClashRuleSetIPCIDROut(buf *bytes.Buffer, entryC return nil } -func (t *TextOut) marshalBytesForSurgeRuleSetOut(buf *bytes.Buffer, entryCidr []string) error { +func (t *text_out) marshalBytesForSurgeRuleSetOut(buf *bytes.Buffer, entryCidr []string) error { for _, cidr := range entryCidr { ip, _, err := net.ParseCIDR(cidr) if err != nil { @@ -173,7 +231,7 @@ func (t *TextOut) marshalBytesForSurgeRuleSetOut(buf *bytes.Buffer, entryCidr [] return nil } -func (t *TextOut) writeFile(filename string, data []byte) error { +func (t *text_out) writeFile(filename string, data []byte) error { if err := os.MkdirAll(t.OutputDir, 0755); err != nil { return err } diff --git a/plugin/plaintext/json_in.go b/plugin/plaintext/json_in.go index a4643609..221f5a0e 100644 --- a/plugin/plaintext/json_in.go +++ b/plugin/plaintext/json_in.go @@ -13,10 +13,10 @@ const ( func init() { lib.RegisterInputConfigCreator(TypeJSONIn, func(action lib.Action, data json.RawMessage) (lib.InputConverter, error) { - return newTextIn(TypeJSONIn, DescJSONIn, action, data) + return NewTextInFromBytes(TypeJSONIn, DescJSONIn, action, data) }) - lib.RegisterInputConverter(TypeJSONIn, &TextIn{ + lib.RegisterInputConverter(TypeJSONIn, &text_in{ Description: DescJSONIn, }) } diff --git a/plugin/plaintext/surge_in.go b/plugin/plaintext/surge_in.go index 7621d0a1..32c99f2e 100644 --- a/plugin/plaintext/surge_in.go +++ b/plugin/plaintext/surge_in.go @@ -18,9 +18,9 @@ const ( func init() { lib.RegisterInputConfigCreator(TypeSurgeRuleSetIn, func(action lib.Action, data json.RawMessage) (lib.InputConverter, error) { - return newTextIn(TypeSurgeRuleSetIn, DescSurgeRuleSetIn, action, data) + return NewTextInFromBytes(TypeSurgeRuleSetIn, DescSurgeRuleSetIn, action, data) }) - lib.RegisterInputConverter(TypeSurgeRuleSetIn, &TextIn{ + lib.RegisterInputConverter(TypeSurgeRuleSetIn, &text_in{ Description: DescSurgeRuleSetIn, }) } diff --git a/plugin/plaintext/surge_out.go b/plugin/plaintext/surge_out.go index 8fe62fb4..30aa2332 100644 --- a/plugin/plaintext/surge_out.go +++ b/plugin/plaintext/surge_out.go @@ -18,9 +18,9 @@ const ( func init() { lib.RegisterOutputConfigCreator(TypeSurgeRuleSetOut, func(action lib.Action, data json.RawMessage) (lib.OutputConverter, error) { - return newTextOut(TypeSurgeRuleSetOut, DescSurgeRuleSetOut, action, data) + return NewTextOutFromBytes(TypeSurgeRuleSetOut, DescSurgeRuleSetOut, action, data) }) - lib.RegisterOutputConverter(TypeSurgeRuleSetOut, &TextOut{ + lib.RegisterOutputConverter(TypeSurgeRuleSetOut, &text_out{ Description: DescSurgeRuleSetOut, }) } diff --git a/plugin/plaintext/text_in.go b/plugin/plaintext/text_in.go index a75b1b12..40572e2e 100644 --- a/plugin/plaintext/text_in.go +++ b/plugin/plaintext/text_in.go @@ -19,14 +19,86 @@ const ( func init() { lib.RegisterInputConfigCreator(TypeTextIn, func(action lib.Action, data json.RawMessage) (lib.InputConverter, error) { - return newTextIn(TypeTextIn, DescTextIn, action, data) + return NewTextInFromBytes(TypeTextIn, DescTextIn, action, data) }) - lib.RegisterInputConverter(TypeTextIn, &TextIn{ + lib.RegisterInputConverter(TypeTextIn, &text_in{ Description: DescTextIn, }) } -func newTextIn(iType string, iDesc string, action lib.Action, data json.RawMessage) (lib.InputConverter, error) { +func NewTextIn(iType string, iDesc string, action lib.Action, opts ...lib.InputOption) lib.InputConverter { + t := &text_in{ + Type: iType, + Action: action, + Description: iDesc, + } + + for _, opt := range opts { + if opt != nil { + opt(t) + } + } + + return t +} + +func WithNameAndURI(name, uri string) lib.InputOption { + return func(t lib.InputConverter) { + t.(*text_in).Name = strings.TrimSpace(name) + t.(*text_in).URI = strings.TrimSpace(uri) + } +} + +func WithIPOrCIDR(ipOrCIDR []string) lib.InputOption { + return func(t lib.InputConverter) { + t.(*text_in).IPOrCIDR = ipOrCIDR + } +} + +func WithInputDir(dir string) lib.InputOption { + return func(t lib.InputConverter) { + t.(*text_in).InputDir = strings.TrimSpace(dir) + } +} + +func WithInputWantedList(lists []string) lib.InputOption { + return func(t lib.InputConverter) { + wantList := make(map[string]bool) + for _, want := range lists { + if want = strings.ToUpper(strings.TrimSpace(want)); want != "" { + wantList[want] = true + } + } + + t.(*text_in).Want = wantList + } +} + +func WithInputOnlyIPType(onlyIPType lib.IPType) lib.InputOption { + return func(t lib.InputConverter) { + t.(*text_in).OnlyIPType = onlyIPType + } +} + +func WithJSONPath(jsonPath []string) lib.InputOption { + return func(t lib.InputConverter) { + t.(*text_in).JSONPath = jsonPath + } +} + +func WithRemovePrefixesInLine(prefixes []string) lib.InputOption { + return func(t lib.InputConverter) { + t.(*text_in).RemovePrefixesInLine = prefixes + } +} + +func WithRemoveSuffixesInLine(suffixes []string) lib.InputOption { + return func(t lib.InputConverter) { + t.(*text_in).RemoveSuffixesInLine = suffixes + } +} + +func NewTextInFromBytes(iType string, iDesc string, action lib.Action, data []byte) (lib.InputConverter, error) { var tmp struct { Name string `json:"name"` URI string `json:"uri"` @@ -69,44 +141,32 @@ func newTextIn(iType string, iDesc string, action lib.Action, data json.RawMessa return nil, fmt.Errorf("❌ [type %s | action %s] inputDir is not allowed to be used with name or uri or ipOrCIDR", iType, 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: iType, - Action: action, - Description: iDesc, - Name: tmp.Name, - URI: tmp.URI, - IPOrCIDR: tmp.IPOrCIDR, - InputDir: tmp.InputDir, - Want: wantList, - OnlyIPType: tmp.OnlyIPType, - - JSONPath: tmp.JSONPath, - RemovePrefixesInLine: tmp.RemovePrefixesInLine, - RemoveSuffixesInLine: tmp.RemoveSuffixesInLine, - }, nil + return NewTextIn( + iType, iDesc, action, + WithNameAndURI(tmp.Name, tmp.URI), + WithIPOrCIDR(tmp.IPOrCIDR), + WithInputDir(tmp.InputDir), + WithInputWantedList(tmp.Want), + WithInputOnlyIPType(tmp.OnlyIPType), + WithJSONPath(tmp.JSONPath), + WithRemovePrefixesInLine(tmp.RemovePrefixesInLine), + WithRemoveSuffixesInLine(tmp.RemoveSuffixesInLine), + ), nil } -func (t *TextIn) GetType() string { +func (t *text_in) GetType() string { return t.Type } -func (t *TextIn) GetAction() lib.Action { +func (t *text_in) GetAction() lib.Action { return t.Action } -func (t *TextIn) GetDescription() string { +func (t *text_in) GetDescription() string { return t.Description } -func (t *TextIn) Input(container lib.Container) (lib.Container, error) { +func (t *text_in) Input(container lib.Container) (lib.Container, error) { entries := make(map[string]*lib.Entry) var err error @@ -162,7 +222,7 @@ func (t *TextIn) Input(container lib.Container) (lib.Container, error) { return container, nil } -func (t *TextIn) walkDir(dir string, entries map[string]*lib.Entry) error { +func (t *text_in) walkDir(dir string, entries map[string]*lib.Entry) error { err := filepath.Walk(dir, func(path string, info os.FileInfo, err error) error { if err != nil { return err @@ -181,7 +241,7 @@ func (t *TextIn) walkDir(dir string, entries map[string]*lib.Entry) error { return err } -func (t *TextIn) walkLocalFile(path, name string, entries map[string]*lib.Entry) error { +func (t *text_in) walkLocalFile(path, name string, entries map[string]*lib.Entry) error { entryName := "" name = strings.TrimSpace(name) if name != "" { @@ -225,7 +285,7 @@ func (t *TextIn) walkLocalFile(path, name string, entries map[string]*lib.Entry) return nil } -func (t *TextIn) walkRemoteFile(url, name string, entries map[string]*lib.Entry) error { +func (t *text_in) walkRemoteFile(url, name string, entries map[string]*lib.Entry) error { resp, err := http.Get(url) if err != nil { return err @@ -252,7 +312,7 @@ func (t *TextIn) walkRemoteFile(url, name string, entries map[string]*lib.Entry) return nil } -func (t *TextIn) appendIPOrCIDR(ipOrCIDR []string, name string, entries map[string]*lib.Entry) error { +func (t *text_in) appendIPOrCIDR(ipOrCIDR []string, name string, entries map[string]*lib.Entry) error { name = strings.ToUpper(name) entry, found := entries[name] diff --git a/plugin/plaintext/text_out.go b/plugin/plaintext/text_out.go index 06f4df63..191f067c 100644 --- a/plugin/plaintext/text_out.go +++ b/plugin/plaintext/text_out.go @@ -16,26 +16,26 @@ const ( func init() { lib.RegisterOutputConfigCreator(TypeTextOut, func(action lib.Action, data json.RawMessage) (lib.OutputConverter, error) { - return newTextOut(TypeTextOut, DescTextOut, action, data) + return NewTextOutFromBytes(TypeTextOut, DescTextOut, action, data) }) - lib.RegisterOutputConverter(TypeTextOut, &TextOut{ + lib.RegisterOutputConverter(TypeTextOut, &text_out{ Description: DescTextOut, }) } -func (t *TextOut) GetType() string { +func (t *text_out) GetType() string { return t.Type } -func (t *TextOut) GetAction() lib.Action { +func (t *text_out) GetAction() lib.Action { return t.Action } -func (t *TextOut) GetDescription() string { +func (t *text_out) GetDescription() string { return t.Description } -func (t *TextOut) Output(container lib.Container) error { +func (t *text_out) Output(container lib.Container) error { for _, name := range t.filterAndSortList(container) { entry, found := container.GetEntry(name) if !found { @@ -57,7 +57,7 @@ func (t *TextOut) Output(container lib.Container) error { return nil } -func (t *TextOut) filterAndSortList(container lib.Container) []string { +func (t *text_out) filterAndSortList(container lib.Container) []string { excludeMap := make(map[string]bool) for _, exclude := range t.Exclude { if exclude = strings.ToUpper(strings.TrimSpace(exclude)); exclude != "" { |
