diff options
| author | Loyalsoldier <[email protected]> | 2024-07-06 18:04:33 +0800 |
|---|---|---|
| committer | Loyalsoldier <[email protected]> | 2024-07-06 18:04:33 +0800 |
| commit | e3800440ce05aa1b8f27d56f47bbeef20f9499c6 (patch) | |
| tree | 5c85e84b7c02713b75738649e483b5758027d011 /plugin/v2ray | |
| parent | 5843ee29c435b393bec57a367775c2f4e266eedc (diff) | |
Fix: remove entry & prefix
Diffstat (limited to 'plugin/v2ray')
| -rw-r--r-- | plugin/v2ray/dat_in.go | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/plugin/v2ray/dat_in.go b/plugin/v2ray/dat_in.go index 65b9a674..5baf32f2 100644 --- a/plugin/v2ray/dat_in.go +++ b/plugin/v2ray/dat_in.go @@ -92,7 +92,7 @@ func (g *geoIPDatIn) Input(container lib.Container) (lib.Container, error) { } if len(entries) == 0 { - return nil, fmt.Errorf("❌ [type %s | action %s] no entry is newly generated", typeGeoIPdatIn, g.Action) + return nil, fmt.Errorf("❌ [type %s | action %s] no entry is generated", typeGeoIPdatIn, g.Action) } var ignoreIPType lib.IgnoreIPOption @@ -123,7 +123,11 @@ func (g *geoIPDatIn) Input(container lib.Container) (lib.Container, error) { return nil, err } case lib.ActionRemove: - container.Remove(name, ignoreIPType) + if err := container.Remove(entry, lib.CaseRemovePrefix, ignoreIPType); err != nil { + return nil, err + } + default: + return nil, lib.ErrUnknownAction } } @@ -174,26 +178,16 @@ func (g *geoIPDatIn) generateEntries(reader io.Reader, entries map[string]*lib.E } for _, geoip := range geoipList.Entry { - var entry *lib.Entry name := geoip.CountryCode - if theEntry, found := entries[name]; found { - fmt.Printf("⚠️ [type %s | action %s] found duplicated entry: %s. Process anyway\n", typeGeoIPdatIn, g.Action, name) - entry = theEntry - } else { + entry, found := entries[name] + if !found { entry = lib.NewEntry(name) } for _, v2rayCIDR := range geoip.Cidr { ipStr := net.IP(v2rayCIDR.GetIp()).String() + "/" + fmt.Sprint(v2rayCIDR.GetPrefix()) - switch g.Action { - case lib.ActionAdd: - if err := entry.AddPrefix(ipStr); err != nil { - return err - } - case lib.ActionRemove: - if err := entry.RemovePrefix(ipStr); err != nil { - return err - } + if err := entry.AddPrefix(ipStr); err != nil { + return err } } |
