diff options
| author | loyalsoldier <[email protected]> | 2021-10-04 15:41:26 +0800 |
|---|---|---|
| committer | loyalsoldier <[email protected]> | 2021-10-04 15:41:26 +0800 |
| commit | 0f88644cdf10877e495a140e2eefd9fa69399dd1 (patch) | |
| tree | 835005dc3c8cacd342ab8bae094bc58d940f2333 | |
| parent | 11925f1ee7190145a4105e4edc7e6ed98f99d304 (diff) | |
Feat: remove unused replace action
| -rw-r--r-- | lib/lib.go | 34 | ||||
| -rw-r--r-- | plugin/maxmind/country_csv.go | 2 | ||||
| -rw-r--r-- | plugin/plaintext/text_in.go | 2 | ||||
| -rw-r--r-- | plugin/special/private.go | 2 | ||||
| -rw-r--r-- | plugin/special/test.go | 2 |
5 files changed, 6 insertions, 36 deletions
@@ -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 } |
