From 0f88644cdf10877e495a140e2eefd9fa69399dd1 Mon Sep 17 00:00:00 2001 From: loyalsoldier <10487845+Loyalsoldier@users.noreply.github.com> Date: Mon, 4 Oct 2021 15:41:26 +0800 Subject: Feat: remove unused replace action --- lib/lib.go | 34 ++++++---------------------------- plugin/maxmind/country_csv.go | 2 -- plugin/plaintext/text_in.go | 2 -- plugin/special/private.go | 2 -- plugin/special/test.go | 2 -- 5 files changed, 6 insertions(+), 36 deletions(-) diff --git a/lib/lib.go b/lib/lib.go index c3203eeb..440628ec 100644 --- a/lib/lib.go +++ b/lib/lib.go @@ -11,20 +11,18 @@ import ( ) const ( - ActionAdd Action = "add" - ActionRemove Action = "remove" - ActionReplace Action = "replace" - ActionOutput Action = "output" + ActionAdd Action = "add" + ActionRemove Action = "remove" + ActionOutput Action = "output" IPv4 IPType = "ipv4" IPv6 IPType = "ipv6" ) var ActionsRegistry = map[Action]bool{ - ActionAdd: true, - ActionRemove: true, - ActionReplace: true, - ActionOutput: true, + ActionAdd: true, + ActionRemove: true, + ActionOutput: true, } type Action string @@ -326,7 +324,6 @@ type Container interface { GetEntry(name string) (*Entry, bool) Add(entry *Entry, opts ...IgnoreIPOption) error Remove(name string, opts ...IgnoreIPOption) - Replace(entry *Entry, opts ...IgnoreIPOption) Loop() <-chan *Entry } @@ -457,22 +454,3 @@ func (c *container) Remove(name string, opts ...IgnoreIPOption) { c.entries.Delete(name) } } - -func (c *container) Replace(entry *Entry, opts ...IgnoreIPOption) { - var ignoreIPType IPType - for _, opt := range opts { - if opt != nil { - ignoreIPType = opt() - } - } - - switch ignoreIPType { - case IPv4: - entry.ipv4Builder = nil - case IPv6: - entry.ipv6Builder = nil - } - - name := entry.GetName() - c.entries.Store(name, entry) -} diff --git a/plugin/maxmind/country_csv.go b/plugin/maxmind/country_csv.go index 6394e375..4608f121 100644 --- a/plugin/maxmind/country_csv.go +++ b/plugin/maxmind/country_csv.go @@ -129,8 +129,6 @@ func (g *geoLite2CountryCSV) Input(container lib.Container) (lib.Container, erro } case lib.ActionRemove: container.Remove(name, ignoreIPType) - case lib.ActionReplace: - container.Replace(entry, ignoreIPType) default: return nil, lib.ErrUnknownAction } diff --git a/plugin/plaintext/text_in.go b/plugin/plaintext/text_in.go index 64ad3ad3..add60a96 100644 --- a/plugin/plaintext/text_in.go +++ b/plugin/plaintext/text_in.go @@ -117,8 +117,6 @@ func (t *textIn) Input(container lib.Container) (lib.Container, error) { } case lib.ActionRemove: container.Remove(entry.GetName(), ignoreIPType) - case lib.ActionReplace: - container.Replace(entry, ignoreIPType) } } diff --git a/plugin/special/private.go b/plugin/special/private.go index e8f231ef..f0e43996 100644 --- a/plugin/special/private.go +++ b/plugin/special/private.go @@ -84,8 +84,6 @@ func (p *private) Input(container lib.Container) (lib.Container, error) { } case lib.ActionRemove: container.Remove(entryNamePrivate) - case lib.ActionReplace: - container.Replace(entry) default: return nil, lib.ErrUnknownAction } diff --git a/plugin/special/test.go b/plugin/special/test.go index 2700b61e..9a19004f 100644 --- a/plugin/special/test.go +++ b/plugin/special/test.go @@ -66,8 +66,6 @@ func (t *test) Input(container lib.Container) (lib.Container, error) { } case lib.ActionRemove: container.Remove(entryNameTest) - case lib.ActionReplace: - container.Replace(entry) default: return nil, lib.ErrUnknownAction } -- cgit v1.3.1