summaryrefslogtreecommitdiff
path: root/plugin
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
parent1fd7373f45810501015373bf202948e8c4fdf2e9 (diff)
Diffstat (limited to 'plugin')
-rw-r--r--plugin/maxmind/maxmind_asn_csv_in.go8
-rw-r--r--plugin/maxmind/maxmind_country_csv_in.go8
-rw-r--r--plugin/maxmind/maxmind_country_mmdb_in.go8
-rw-r--r--plugin/maxmind/maxmind_country_mmdb_out.go11
-rw-r--r--plugin/mihomo/mrs_in.go8
-rw-r--r--plugin/mihomo/mrs_out.go11
-rw-r--r--plugin/plaintext/common_out.go12
-rw-r--r--plugin/plaintext/text_in.go8
-rw-r--r--plugin/singbox/srs_in.go8
-rw-r--r--plugin/singbox/srs_out.go11
-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
-rw-r--r--plugin/v2ray/dat_in.go8
-rw-r--r--plugin/v2ray/dat_out.go12
16 files changed, 16 insertions, 132 deletions
diff --git a/plugin/maxmind/maxmind_asn_csv_in.go b/plugin/maxmind/maxmind_asn_csv_in.go
index 5b42be59..d924e3f9 100644
--- a/plugin/maxmind/maxmind_asn_csv_in.go
+++ b/plugin/maxmind/maxmind_asn_csv_in.go
@@ -137,13 +137,7 @@ func (g *GeoLite2ASNCSVIn) Input(container lib.Container) (lib.Container, error)
return nil, fmt.Errorf("❌ [type %s | action %s] no entry is generated", g.Type, g.Action)
}
- var ignoreIPType lib.IgnoreIPOption
- switch g.OnlyIPType {
- case lib.IPv4:
- ignoreIPType = lib.IgnoreIPv6
- case lib.IPv6:
- ignoreIPType = lib.IgnoreIPv4
- }
+ ignoreIPType := lib.GetIgnoreIPType(g.OnlyIPType)
for _, entry := range entries {
switch g.Action {
diff --git a/plugin/maxmind/maxmind_country_csv_in.go b/plugin/maxmind/maxmind_country_csv_in.go
index da70c281..93d38c37 100644
--- a/plugin/maxmind/maxmind_country_csv_in.go
+++ b/plugin/maxmind/maxmind_country_csv_in.go
@@ -125,13 +125,7 @@ func (g *GeoLite2CountryCSVIn) Input(container lib.Container) (lib.Container, er
return nil, fmt.Errorf("❌ [type %s | action %s] no entry is generated", g.Type, g.Action)
}
- var ignoreIPType lib.IgnoreIPOption
- switch g.OnlyIPType {
- case lib.IPv4:
- ignoreIPType = lib.IgnoreIPv6
- case lib.IPv6:
- ignoreIPType = lib.IgnoreIPv4
- }
+ ignoreIPType := lib.GetIgnoreIPType(g.OnlyIPType)
for _, entry := range entries {
switch g.Action {
diff --git a/plugin/maxmind/maxmind_country_mmdb_in.go b/plugin/maxmind/maxmind_country_mmdb_in.go
index be867b9b..1f6d5386 100644
--- a/plugin/maxmind/maxmind_country_mmdb_in.go
+++ b/plugin/maxmind/maxmind_country_mmdb_in.go
@@ -69,13 +69,7 @@ func (g *GeoLite2CountryMMDBIn) Input(container lib.Container) (lib.Container, e
return nil, fmt.Errorf("❌ [type %s | action %s] no entry is generated", g.Type, g.Action)
}
- var ignoreIPType lib.IgnoreIPOption
- switch g.OnlyIPType {
- case lib.IPv4:
- ignoreIPType = lib.IgnoreIPv6
- case lib.IPv6:
- ignoreIPType = lib.IgnoreIPv4
- }
+ ignoreIPType := lib.GetIgnoreIPType(g.OnlyIPType)
for _, entry := range entries {
switch g.Action {
diff --git a/plugin/maxmind/maxmind_country_mmdb_out.go b/plugin/maxmind/maxmind_country_mmdb_out.go
index 4cf4cef6..fc72e83c 100644
--- a/plugin/maxmind/maxmind_country_mmdb_out.go
+++ b/plugin/maxmind/maxmind_country_mmdb_out.go
@@ -176,16 +176,7 @@ func (g *GeoLite2CountryMMDBOut) filterAndSortList(container lib.Container) []st
}
func (g *GeoLite2CountryMMDBOut) marshalData(writer *mmdbwriter.Tree, entry *lib.Entry, extraInfo map[string]any) error {
- var entryCidr []string
- var err error
- switch g.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(g.OnlyIPType))
if err != nil {
return err
}
diff --git a/plugin/mihomo/mrs_in.go b/plugin/mihomo/mrs_in.go
index 42376465..cc80f245 100644
--- a/plugin/mihomo/mrs_in.go
+++ b/plugin/mihomo/mrs_in.go
@@ -126,13 +126,7 @@ func (m *MRSIn) Input(container lib.Container) (lib.Container, error) {
return nil, fmt.Errorf("❌ [type %s | action %s] no entry is generated", m.Type, m.Action)
}
- var ignoreIPType lib.IgnoreIPOption
- switch m.OnlyIPType {
- case lib.IPv4:
- ignoreIPType = lib.IgnoreIPv6
- case lib.IPv6:
- ignoreIPType = lib.IgnoreIPv4
- }
+ ignoreIPType := lib.GetIgnoreIPType(m.OnlyIPType)
for _, entry := range entries {
switch m.Action {
diff --git a/plugin/mihomo/mrs_out.go b/plugin/mihomo/mrs_out.go
index 7d63788c..e8d65e9f 100644
--- a/plugin/mihomo/mrs_out.go
+++ b/plugin/mihomo/mrs_out.go
@@ -138,16 +138,7 @@ func (m *MRSOut) filterAndSortList(container lib.Container) []string {
}
func (m *MRSOut) generate(entry *lib.Entry) error {
- var ipRanges []netipx.IPRange
- var err error
- switch m.OnlyIPType {
- case lib.IPv4:
- ipRanges, err = entry.MarshalIPRange(lib.IgnoreIPv6)
- case lib.IPv6:
- ipRanges, err = entry.MarshalIPRange(lib.IgnoreIPv4)
- default:
- ipRanges, err = entry.MarshalIPRange()
- }
+ ipRanges, err := entry.MarshalIPRange(lib.GetIgnoreIPType(m.OnlyIPType))
if err != nil {
return err
}
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)
diff --git a/plugin/singbox/srs_in.go b/plugin/singbox/srs_in.go
index 68ccd461..348f4563 100644
--- a/plugin/singbox/srs_in.go
+++ b/plugin/singbox/srs_in.go
@@ -120,13 +120,7 @@ func (s *SRSIn) Input(container lib.Container) (lib.Container, error) {
return nil, fmt.Errorf("❌ [type %s | action %s] no entry is generated", s.Type, s.Action)
}
- var ignoreIPType lib.IgnoreIPOption
- switch s.OnlyIPType {
- case lib.IPv4:
- ignoreIPType = lib.IgnoreIPv6
- case lib.IPv6:
- ignoreIPType = lib.IgnoreIPv4
- }
+ ignoreIPType := lib.GetIgnoreIPType(s.OnlyIPType)
for _, entry := range entries {
switch s.Action {
diff --git a/plugin/singbox/srs_out.go b/plugin/singbox/srs_out.go
index e2fb767e..535eb6b8 100644
--- a/plugin/singbox/srs_out.go
+++ b/plugin/singbox/srs_out.go
@@ -151,16 +151,7 @@ func (s *SRSOut) generate(entry *lib.Entry) error {
}
func (s *SRSOut) marshalRuleSet(entry *lib.Entry) (*option.PlainRuleSet, error) {
- var entryCidr []string
- var err error
- switch s.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(s.OnlyIPType))
if err != nil {
return nil, err
}
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
}
diff --git a/plugin/v2ray/dat_in.go b/plugin/v2ray/dat_in.go
index 0c5cb6a0..33a24061 100644
--- a/plugin/v2ray/dat_in.go
+++ b/plugin/v2ray/dat_in.go
@@ -102,13 +102,7 @@ func (g *GeoIPDatIn) Input(container lib.Container) (lib.Container, error) {
return nil, fmt.Errorf("❌ [type %s | action %s] no entry is generated", g.Type, g.Action)
}
- var ignoreIPType lib.IgnoreIPOption
- switch g.OnlyIPType {
- case lib.IPv4:
- ignoreIPType = lib.IgnoreIPv6
- case lib.IPv6:
- ignoreIPType = lib.IgnoreIPv4
- }
+ ignoreIPType := lib.GetIgnoreIPType(g.OnlyIPType)
for _, entry := range entries {
switch g.Action {
diff --git a/plugin/v2ray/dat_out.go b/plugin/v2ray/dat_out.go
index 91062970..5137e828 100644
--- a/plugin/v2ray/dat_out.go
+++ b/plugin/v2ray/dat_out.go
@@ -4,7 +4,6 @@ import (
"encoding/json"
"fmt"
"log"
- "net/netip"
"os"
"path/filepath"
"slices"
@@ -182,16 +181,7 @@ func (g *GeoIPDatOut) filterAndSortList(container lib.Container) []string {
}
func (g *GeoIPDatOut) generateGeoIP(entry *lib.Entry) (*GeoIP, error) {
- var entryCidr []netip.Prefix
- var err error
- switch g.OnlyIPType {
- case lib.IPv4:
- entryCidr, err = entry.MarshalPrefix(lib.IgnoreIPv6)
- case lib.IPv6:
- entryCidr, err = entry.MarshalPrefix(lib.IgnoreIPv4)
- default:
- entryCidr, err = entry.MarshalPrefix()
- }
+ entryCidr, err := entry.MarshalPrefix(lib.GetIgnoreIPType(g.OnlyIPType))
if err != nil {
return nil, err
}