summaryrefslogtreecommitdiff
path: root/plugin/special
diff options
context:
space:
mode:
authorLoyalsoldier <[email protected]>2026-03-06 10:40:04 +0800
committerLoyalsoldier <[email protected]>2026-03-06 10:40:04 +0800
commit54c52d334ff35b6583be619b3f665e972ae20d98 (patch)
tree523c1be0ae5b7e4390fb449a411197f5959d547c /plugin/special
parent1fd7373f45810501015373bf202948e8c4fdf2e9 (diff)
Diffstat (limited to 'plugin/special')
-rw-r--r--plugin/special/cutter.go8
-rw-r--r--plugin/special/private.go8
-rw-r--r--plugin/special/stdin.go8
-rw-r--r--plugin/special/stdout.go11
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
}