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/special | |
| parent | 1fd7373f45810501015373bf202948e8c4fdf2e9 (diff) | |
Chore: extract common GetIgnoreIPType logic202604142159202604090028202604020031202603260032202603190030202603120023202603061527
Diffstat (limited to 'plugin/special')
| -rw-r--r-- | plugin/special/cutter.go | 8 | ||||
| -rw-r--r-- | plugin/special/private.go | 8 | ||||
| -rw-r--r-- | plugin/special/stdin.go | 8 | ||||
| -rw-r--r-- | plugin/special/stdout.go | 11 |
4 files changed, 4 insertions, 31 deletions
diff --git a/plugin/special/cutter.go b/plugin/special/cutter.go index a96431e7..509cddbb 100644 --- a/plugin/special/cutter.go +++ b/plugin/special/cutter.go @@ -80,13 +80,7 @@ func (c *Cutter) GetDescription() string { } func (c *Cutter) Input(container lib.Container) (lib.Container, error) { - var ignoreIPType lib.IgnoreIPOption - switch c.OnlyIPType { - case lib.IPv4: - ignoreIPType = lib.IgnoreIPv6 - case lib.IPv6: - ignoreIPType = lib.IgnoreIPv4 - } + ignoreIPType := lib.GetIgnoreIPType(c.OnlyIPType) for entry := range container.Loop() { if len(c.Want) > 0 && !c.Want[entry.GetName()] { diff --git a/plugin/special/private.go b/plugin/special/private.go index 5c137687..1bc170bc 100644 --- a/plugin/special/private.go +++ b/plugin/special/private.go @@ -95,13 +95,7 @@ func (p *Private) Input(container lib.Container) (lib.Container, error) { } } - var ignoreIPType lib.IgnoreIPOption - switch p.OnlyIPType { - case lib.IPv4: - ignoreIPType = lib.IgnoreIPv6 - case lib.IPv6: - ignoreIPType = lib.IgnoreIPv4 - } + ignoreIPType := lib.GetIgnoreIPType(p.OnlyIPType) switch p.Action { case lib.ActionAdd: diff --git a/plugin/special/stdin.go b/plugin/special/stdin.go index 779a4cbd..f2f9cf9c 100644 --- a/plugin/special/stdin.go +++ b/plugin/special/stdin.go @@ -95,13 +95,7 @@ func (s *Stdin) Input(container lib.Container) (lib.Container, error) { return nil, err } - var ignoreIPType lib.IgnoreIPOption - switch s.OnlyIPType { - case lib.IPv4: - ignoreIPType = lib.IgnoreIPv6 - case lib.IPv6: - ignoreIPType = lib.IgnoreIPv4 - } + ignoreIPType := lib.GetIgnoreIPType(s.OnlyIPType) switch s.Action { case lib.ActionAdd: diff --git a/plugin/special/stdout.go b/plugin/special/stdout.go index ed8467ed..614deaac 100644 --- a/plugin/special/stdout.go +++ b/plugin/special/stdout.go @@ -126,16 +126,7 @@ func (s *Stdout) filterAndSortList(container lib.Container) []string { } func (s *Stdout) generateCIDRList(entry *lib.Entry) ([]string, error) { - var entryList []string - var err error - switch s.OnlyIPType { - case lib.IPv4: - entryList, err = entry.MarshalText(lib.IgnoreIPv6) - case lib.IPv6: - entryList, err = entry.MarshalText(lib.IgnoreIPv4) - default: - entryList, err = entry.MarshalText() - } + entryList, err := entry.MarshalText(lib.GetIgnoreIPType(s.OnlyIPType)) if err != nil { return nil, err } |
