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/v2ray | |
| parent | 1fd7373f45810501015373bf202948e8c4fdf2e9 (diff) | |
Chore: extract common GetIgnoreIPType logic202604142159202604090028202604020031202603260032202603190030202603120023202603061527
Diffstat (limited to 'plugin/v2ray')
| -rw-r--r-- | plugin/v2ray/dat_in.go | 8 | ||||
| -rw-r--r-- | plugin/v2ray/dat_out.go | 12 |
2 files changed, 2 insertions, 18 deletions
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 } |
