From d5767c9eeb6f157ee79e1635e5958be6e2bf108a Mon Sep 17 00:00:00 2001 From: Daniel Czerwonk <daniel@dan-nrw.de> Date: Mon, 14 May 2018 10:32:11 +0200 Subject: [PATCH] renamed Then to FilterAction --- routingtable/filter/filter_test.go | 12 ++++++------ routingtable/filter/term.go | 8 ++++++-- routingtable/filter/term_test.go | 14 +++++++------- routingtable/filter/then.go | 10 ---------- 4 files changed, 19 insertions(+), 25 deletions(-) delete mode 100644 routingtable/filter/then.go diff --git a/routingtable/filter/filter_test.go b/routingtable/filter/filter_test.go index 8b33f125..ce9b733e 100644 --- a/routingtable/filter/filter_test.go +++ b/routingtable/filter/filter_test.go @@ -54,7 +54,7 @@ func TestAddPath(t *testing.T) { prefix: net.NewPfx(0, 0), path: &route.Path{}, term: &Term{ - then: []Then{ + then: []FilterAction{ &actions.AcceptAction{}, }, }, @@ -66,7 +66,7 @@ func TestAddPath(t *testing.T) { prefix: net.NewPfx(0, 0), path: &route.Path{}, term: &Term{ - then: []Then{ + then: []FilterAction{ &actions.RejectAction{}, }, }, @@ -78,7 +78,7 @@ func TestAddPath(t *testing.T) { prefix: net.NewPfx(0, 0), path: &route.Path{}, term: &Term{ - then: []Then{ + then: []FilterAction{ &mockAction{}, &actions.AcceptAction{}, }, @@ -127,7 +127,7 @@ func TestRemovePath(t *testing.T) { prefix: net.NewPfx(0, 0), path: &route.Path{}, term: &Term{ - then: []Then{ + then: []FilterAction{ &actions.AcceptAction{}, }, }, @@ -139,7 +139,7 @@ func TestRemovePath(t *testing.T) { prefix: net.NewPfx(0, 0), path: &route.Path{}, term: &Term{ - then: []Then{ + then: []FilterAction{ &actions.RejectAction{}, }, }, @@ -151,7 +151,7 @@ func TestRemovePath(t *testing.T) { prefix: net.NewPfx(0, 0), path: &route.Path{}, term: &Term{ - then: []Then{ + then: []FilterAction{ &mockAction{}, &actions.AcceptAction{}, }, diff --git a/routingtable/filter/term.go b/routingtable/filter/term.go index 85a88eb8..2f8a47a9 100644 --- a/routingtable/filter/term.go +++ b/routingtable/filter/term.go @@ -5,14 +5,18 @@ import ( "github.com/bio-routing/bio-rd/route" ) +type FilterAction interface { + Do(p net.Prefix, pa *route.Path) (modPath *route.Path, reject bool) +} + // Term matches a path against a list of conditions and performs actions if it matches type Term struct { from []*From - then []Then + then []FilterAction } // NewTerm creates a new term -func NewTerm(from []*From, then []Then) *Term { +func NewTerm(from []*From, then []FilterAction) *Term { t := &Term{ from: from, then: then, diff --git a/routingtable/filter/term_test.go b/routingtable/filter/term_test.go index ee55c712..bd0a00be 100644 --- a/routingtable/filter/term_test.go +++ b/routingtable/filter/term_test.go @@ -25,7 +25,7 @@ func TestProcess(t *testing.T) { prefix net.Prefix path *route.Path from []*From - then []Then + then []FilterAction expectReject bool expectModified bool }{ @@ -34,7 +34,7 @@ func TestProcess(t *testing.T) { prefix: net.NewPfx(strAddr("100.64.0.1"), 8), path: &route.Path{}, from: []*From{}, - then: []Then{ + then: []FilterAction{ &actions.AcceptAction{}, }, expectReject: false, @@ -53,7 +53,7 @@ func TestProcess(t *testing.T) { }, }, }, - then: []Then{ + then: []FilterAction{ &actions.AcceptAction{}, }, expectReject: false, @@ -72,7 +72,7 @@ func TestProcess(t *testing.T) { }, }, }, - then: []Then{ + then: []FilterAction{ &actions.AcceptAction{}, }, expectReject: true, @@ -91,7 +91,7 @@ func TestProcess(t *testing.T) { }, }, }, - then: []Then{ + then: []FilterAction{ &mockAction{}, }, expectReject: false, @@ -110,7 +110,7 @@ func TestProcess(t *testing.T) { }, }, }, - then: []Then{ + then: []FilterAction{ &mockAction{}, &actions.AcceptAction{}, }, @@ -137,7 +137,7 @@ func TestProcess(t *testing.T) { }, }, }, - then: []Then{ + then: []FilterAction{ &actions.AcceptAction{}, }, expectReject: false, diff --git a/routingtable/filter/then.go b/routingtable/filter/then.go deleted file mode 100644 index 920daf43..00000000 --- a/routingtable/filter/then.go +++ /dev/null @@ -1,10 +0,0 @@ -package filter - -import ( - "github.com/bio-routing/bio-rd/net" - "github.com/bio-routing/bio-rd/route" -) - -type Then interface { - Do(p net.Prefix, pa *route.Path) (modPath *route.Path, reject bool) -} -- GitLab