diff options
| author | Loyalsoldier <[email protected]> | 2026-03-06 10:40:04 +0800 |
|---|---|---|
| committer | Loyalsoldier <[email protected]> | 2026-03-06 10:40:04 +0800 |
| commit | 54c52d334ff35b6583be619b3f665e972ae20d98 (patch) | |
| tree | 523c1be0ae5b7e4390fb449a411197f5959d547c /plugin/plaintext | |
| parent | 1fd7373f45810501015373bf202948e8c4fdf2e9 (diff) | |
Chore: extract common GetIgnoreIPType logic202604142159202604090028202604020031202603260032202603190030202603120023202603061527
Diffstat (limited to 'plugin/plaintext')
| -rw-r--r-- | plugin/plaintext/common_out.go | 12 | ||||
| -rw-r--r-- | plugin/plaintext/text_in.go | 8 |
2 files changed, 2 insertions, 18 deletions
diff --git a/plugin/plaintext/common_out.go b/plugin/plaintext/common_out.go index e772293a..cc7ba41e 100644 --- a/plugin/plaintext/common_out.go +++ b/plugin/plaintext/common_out.go @@ -83,17 +83,7 @@ func newTextOut(iType string, iDesc string, action lib.Action, data json.RawMess } func (t *TextOut) marshalBytes(entry *lib.Entry) ([]byte, error) { - var err error - - var entryCidr []string - switch t.OnlyIPType { - case lib.IPv4: - entryCidr, err = entry.MarshalText(lib.IgnoreIPv6) - case lib.IPv6: - entryCidr, err = entry.MarshalText(lib.IgnoreIPv4) - default: - entryCidr, err = entry.MarshalText() - } + entryCidr, err := entry.MarshalText(lib.GetIgnoreIPType(t.OnlyIPType)) if err != nil { return nil, err } diff --git a/plugin/plaintext/text_in.go b/plugin/plaintext/text_in.go index 41fb8177..a75b1b12 100644 --- a/plugin/plaintext/text_in.go +++ b/plugin/plaintext/text_in.go @@ -138,13 +138,7 @@ func (t *TextIn) Input(container lib.Container) (lib.Container, error) { return nil, err } - var ignoreIPType lib.IgnoreIPOption - switch t.OnlyIPType { - case lib.IPv4: - ignoreIPType = lib.IgnoreIPv6 - case lib.IPv6: - ignoreIPType = lib.IgnoreIPv4 - } + ignoreIPType := lib.GetIgnoreIPType(t.OnlyIPType) if len(entries) == 0 { return nil, fmt.Errorf("❌ [type %s | action %s] no entry is generated", t.Type, t.Action) |
