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/maxmind | |
| parent | 1fd7373f45810501015373bf202948e8c4fdf2e9 (diff) | |
Chore: extract common GetIgnoreIPType logic202604142159202604090028202604020031202603260032202603190030202603120023202603061527
Diffstat (limited to 'plugin/maxmind')
| -rw-r--r-- | plugin/maxmind/maxmind_asn_csv_in.go | 8 | ||||
| -rw-r--r-- | plugin/maxmind/maxmind_country_csv_in.go | 8 | ||||
| -rw-r--r-- | plugin/maxmind/maxmind_country_mmdb_in.go | 8 | ||||
| -rw-r--r-- | plugin/maxmind/maxmind_country_mmdb_out.go | 11 |
4 files changed, 4 insertions, 31 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 } |
